如何设置矩形UIButton的标题?

时间:2014-04-07 13:59:04

标签: ios objective-c uibutton

您是iOS开发的新手,我正在尝试创建矩形UIButton但是按钮标题不可见。下面是我的代码......任何人都可以帮我解决这段代码中的错误...提前感谢...

_locationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
CALayer *layer = [_locationBtn layer];
//[layer setMasksToBounds:YES];
[layer setCornerRadius:0.0];
[layer setBorderWidth:1.0];
[layer setBorderColor:[[UIColor grayColor] CGColor]];

[_locationBtn addTarget:self action:@selector(dropDownMtd) forControlEvents:UIControlEventTouchUpInside];
_locationBtn.frame = CGRectMake(20, 170, 280, 40);
[_locationBtn setTitle:@"Select location" forState:UIControlStateNormal];
[self.view addSubview:_locationBtn];

1 个答案:

答案 0 :(得分:0)

所以解决方案:
问题似乎是按钮标题颜色(我认为颜色与背景颜色相同) 因此,通过将标题颜色(aColor)设置为不同:

[_locationBtn setTitleColor:aColor forState:UIControlStateNormal]
相关问题