Dem*_*rpl 2 xcode uibutton uiview uicolor
我有一个UIView,我已经在我的表视图下面添加了一个按钮:
myUIView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 120,50)];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton setAutoResizingMask:  [UIViewAutoResizingFlexibleWidth|UIViewAutoResizingFlexibleHeight];
[myButton setFrame:CGRectMake(20,0,80,40)];
myButton.titleLabel.textColor = [UIColor blackColor]; //Doesn't seem to work
[myButton setTitle:@"Test" forState:UIControlStateNormal];
myButton.titleLabel.font = [UIFont boldSystemFontOfSize:18];
[myButton setBackgroundImage:[[UIImage imageNamed:@"myImage.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside];
[myUIView addSubView:myButton];
无论我尝试什么,字体似乎总是白色的.我该怎么做才能改变字体的颜色?
你想使用setTitleColor:forState:
[myButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
| 归档时间: | 
 | 
| 查看次数: | 5888 次 | 
| 最近记录: |