iphone - 带有图像的自定义 UIButton

标签 iphone ios uitableview uibutton

我正在尝试设置 UIButton 单元格的附属 View 。但它没有显示。

这是代码

UIButton *accessory = [UIButton buttonWithType:UIButtonTypeCustom];
[accessory setImage:[UIImage imageNamed:@"plus.png"] forState:UIControlStateNormal];
[cell setAccessoryView:accessory];

最佳答案

调用[accessory sizeToFit];根据图片调整其大小。

关于iphone - 带有图像的自定义 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11151550/

相关文章:

ios - 如何从数据源来自另一个 swift 文件的 tableView 激活 segue?

iphone - 如何阻止 UITableView 上的 reloadData 清除删除确认按钮?

ios - 无法将 UITableViewCell 设置为单元格

ios - 蓝牙扫描在后台不工作

iphone - 当 CGRect 是实例变量时如何获得对 CGRect 元素的赋值访问

iphone - Objective-C : Is there a difference between these two statements?

iphone - 在 iPhone 上录制音频 : error with setPreferredIOBufferDuration

ios - 制作自定义的动态表格 View 单元格

ios - 通过开发人员获取更多应用

iOS 在给定角度和半径的情况下以编程方式创建圆形扇区的 UIImage