2016-12-15 5 views

Répondre

2

couleur du premier magasin dans DB UIColor comme celui-ci

string color = yourBtn.BackgroundColor.ToString(); 

convertir ensuite votre couleur UIColor comme

string hex = color.; 
nfloat red = Convert.ToInt32(string.Format("{0}{0}",hex.Substring(0, 1)), 16)/255f; 
nfloat green = Convert.ToInt32(string.Format("{0}{0}",hex.Substring(1, 1)), 16)/255f; 
nfloat blue = Convert.ToInt32(string.Format("{0}{0}",hex.Substring(2, 1)), 16)/255f; 
UIColor color = UIColor.FromRGB(red, green, blue); 

vous devez diviser chaîne à 3 chaînes de sous pour obtenir les codes de couleur rouge, vert, bleu.

1

Vous pouvez utiliser le format de couleur hexadécimal de 8char (comme # ff0a11ff)

Lorsque vous chargez/enregistrer la chaîne, analyser simplement dans un tableau d'octets ou un tableau int, comme UILabel.FromRGBA vous permet de créer une couleur d'eux: https://developer.xamarin.com/api/member/MonoTouch.UIKit.UIColor.FromRGBA/p/System.Int32/System.Int32/System.Int32/System.Int32/

(désolé de donner un anwser et non un commentaire, je n'ai pas la réputation enought)

+1

Correct, un bon post de stackoverflow sur ce http://stackoverflow.com/questions/10310917/uicolor-from-hex-in-monotouch – OrcusZ