您是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];
答案 0 :(得分:0)
所以解决方案:
问题似乎是按钮标题颜色(我认为颜色与背景颜色相同)
因此,通过将标题颜色(aColor
)设置为不同:
[_locationBtn setTitleColor:aColor forState:UIControlStateNormal]