Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何设置UIButton上的标题_Iphone - Fatal编程技术网

Iphone 如何设置UIButton上的标题

Iphone 如何设置UIButton上的标题,iphone,Iphone,如何在ui按钮上设置文本 topYellowButton2 = [UIButton buttonWithType:UIButtonTypeCustom]; topYellowButton2.frame = CGRectMake(80, 0, 90, 20); [topYellowButton2 setTitleColor:[UIColor colorWithRed:0.0 green:0.6 blue:1.0 alpha:1.0] forState:UIControlStateNormal];

如何在
ui按钮上设置文本

topYellowButton2 = [UIButton buttonWithType:UIButtonTypeCustom];
topYellowButton2.frame = CGRectMake(80, 0, 90, 20);

[topYellowButton2 setTitleColor:[UIColor colorWithRed:0.0 green:0.6 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
只需添加以下行:

[topYellowButton2 setTitle:@"my button" forState:UIControlStateNormal];
试试这个

topYellowButton2=[UIButton buttonWithType:UIButtonTypeCustom]; 
topYellowButton2.frame=CGRectMake(80, 0, 90, 20);
[topYellowButton2 setTitle:@"Your Title" forState:UIControlStateNormal];

设置普通和高亮显示的标题

[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateNormal];
[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateHighlighted];
[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateNormal];
[topYellowButton2 setTitle:@"Button Title" forControlState:UIControlStateHighlighted];