自定义UIButton的时候遇到的小问题
出现问题的代码如下:
//选择按钮
UIButton *performerButton = [UIButton buttonWithType:UIButtonTypeCustom];
[performerButton setFrame:CGRectMake(tip.frame.size.width+10.0, y+11.0, 35.0, 25.0)];
[performerButton addTarget:self
action:@selector(setTeleplayType:)
forControlEvents:UIControlEventTouchUpInside];
[self.scrollView addSubview:performerButton];
[performerButton setTitle:@"演员" forState:UIControlStateNormal];
[performerButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
结果是看不到你添加的标题。
问题的关键是如何解决的,呵呵,蠢死我了,其实就是自己设计的button的宽度太小了,没有将字体显示出来.
结果的代码如下修改就好:
//选择按钮
UIButton *performerButton = [UIButton buttonWithType:UIButtonTypeCustom];
[performerButton setFrame:CGRectMake(tip.frame.size.width+10.0, y+11.0, 45.0, 25.0)];
[performerButton addTarget:self
action:@selector(setTeleplayType:)
forControlEvents:UIControlEventTouchUpInside];
[self.scrollView addSubview:performerButton];
[performerButton setTitle:@"演员" forState:UIControlStateNormal];
[performerButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
版权声明
由 davidzhang创作并维护的 Gowhich博客采用创作共用保留署名-非商业-禁止演绎4.0国际许可证。
本文首发于 博客( https://www.gowhich.com ),版权所有,侵权必究。
本文永久链接: https://www.gowhich.com/blog/160
版权声明
由 davidzhang创作并维护的 Gowhich博客采用创作共用保留署名-非商业-禁止演绎4.0国际许可证。
本文首发于 Gowhich博客( https://www.gowhich.com ),版权所有,侵权必究。
本文永久链接: https://www.gowhich.com/blog/160