[《UILabel》 setTextColor:《UIColor*》];
UIColor* 変数 = [《UILabel》 textColor];
[《UILabel》 setBackgroundColor:《UIColor*》];
UIColor* 変数 = [《UILabel》 backgroundColor];
+ blackColorこれらを呼び出せば、基本的な色はすぐに作成できます。例えば、黒を示すUIColorが欲しければ、[UIColor blackColor]とすればいいわけです。実に簡単ですね。
+ darkGrayColor
+ lightGrayColor
+ whiteColor
+ grayColor
+ redColor
+ greenColor
+ blueColor
+ cyanColor
+ yellowColor
+ magentaColor
+ orangeColor
+ purpleColor
+ brownColor
+ clearColor
UIColor* 変数 = [UIColor colorWithRed:赤 green:緑 blue:青 alpha:アルファ];各引数の赤・緑・青・アルファには、0〜1のCGFloat値が指定されます。これでそれぞれの輝度を指定することで、その色を示すインスタンスが得られます。
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
※MyIAppController.h #import <UIKit/UIKit.h> @interface MyIAppViewController : UIViewController { UILabel * label1; UIButton * button1; } @property (nonatomic, retain) IBOutlet UILabel * label1; @property (nonatomic, retain) IBOutlet UIButton * button1; - (IBAction)button1Action:(id)sender; @end ※MyIAppController.m @implementation MyIAppViewController @dynamic label1; @dynamic button1; - (IBAction)button1Action:(id)sender { srand(time(NULL)); UIColor* c = [UIColor colorWithRed: rand() % 100 / 100.0 green:rand() % 100 / 100.0 blue:rand() % 100 / 100.0 alpha:1.0]; [label1 setTextColor:c]; UIColor* c2 = [UIColor colorWithRed: rand() % 100 / 100.0 green:rand() % 100 / 100.0 blue:rand() % 100 / 100.0 alpha:1.0]; [label1 setBackgroundColor:c2]; } ……中略…… @end
<< 前へ | 次へ >> |