ich etwas will alsWie ein Farbbild in iPhone sdk bekommen
UIImage *solid = [UIImage imageWithColor:[UIColor darkGrayColor]];
folgte ein Bild in Bezug auf etwas Farbe zu erstellen.
wie es in iPhone SDK zu tun.
ich etwas will alsWie ein Farbbild in iPhone sdk bekommen
UIImage *solid = [UIImage imageWithColor:[UIColor darkGrayColor]];
folgte ein Bild in Bezug auf etwas Farbe zu erstellen.
wie es in iPhone SDK zu tun.
Sie die Farbe in eine CGContext ziehen und dann ein Bild von ihm erfassen:
- (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size {
//Create a context of the appropriate size
UIGraphicsBeginImageContext(size);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
//Build a rect of appropriate size at origin 0,0
CGRect fillRect = CGRectMake(0,0,size.width,size.height);
//Set the fill color
CGContextSetFillColorWithColor(currentContext, color.CGColor);
//Fill the color
CGContextFillRect(currentContext, fillRect);
//Snap the picture and close the context
UIImage *retval = UIGraphicsGetImageFromCurrentImageContext(void);
UIGraphicsEndImageContext();
return retval;
}
Wenn Sie nur ein festes Rechteck von Farbe zu erzeugen versuchen, warum nicht nur wie
etwas tunUIView *solid = [[UIView alloc] initWithFrame:someFrame];
solid.backgroundColor = [UIColor greyColor];
Und dann fügen Sie die Ansicht zu der Unteransicht, die Sie die Volltonfarbe anzeigen möchten.
(Das heißt, natürlich nur, wenn das, was Sie erreichen wollen. Vielleicht sind Sie nicht)
Ich denke, es gibt eine Methode, die als Zeichnung macht es einfach. Ich sah es irgendwann beim Surfen aber dint erinnere mich daran. Ich dachte daran, es hier zu posten, wenn es jemand weiß. – rkb
Zeichnen ist ~ 7 Zeilen können Sie in einer Komfort-Methode zu wickeln, ich sehe es nicht viel einfacher, es ist nicht genau eine gemeinsame Funktion. –
Betrachte UIGraphicsGetImageFromCurrentImageContext(); anstelle von UIGraphicsGetImageFromCurrentImageContext (void); – LordParsley