自定义UIButton的时候遇到的小问题

{app.params.name}} {app.params.name}} {app.params.name}}

出现问题的代码如下:


//选择按钮
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国际许可证。

本文首发于 Gowhich 博客( https://www.gowhich.com ),版权所有,侵权必究。

本文永久链接: https://www.gowhich.com/blog/160

comments powered by Disqus