Swa*_*lla 3 objective-c uitableview ios
我想编辑UITableViewRowAction我的表格.我的细胞有圆角和边框,我想编辑它的样式RowAction以匹配我的细胞的样式.
据我所知,目前只能backgroundColor更改标题和样式(默认,破坏性,正常...)(链接).但是,我觉得这有点太受限制了?也许我可以UITableViewRowAction创建自己的外观和感觉?任何意见,将不胜感激.
不幸的是我无法发布示例图像,因为我还没有10个代表(哈哈).但是我觉得这个问题很简单,没有视觉表现就能被理解.
小智 7
正如您所说,您可以在行动中改变的唯一事项是:
为了改变UITableViewRowAction的风格,可能的解决方案是使用'patternimage'添加图像.
这是解决方案.我并不是说这是确切的解决方案,因为现在我们无法访问'UITableViewRowAction'的所有属性
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"test" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// show UIActionSheet
}];
float wwidth =[moreAction.title sizeWithAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:15.0]}].width;
wwidth = wwidth+<55 change this value for exact width>;
moreAction.backgroundColor = [[UIColor alloc] initWithPatternImage:[self imageWithImage:[UIImage imageNamed:@"temp.jpg"] scaledToSize:CGSizeMake(wwidth, tableView.rowHeight)]];
UITableViewRowAction *flagAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Flag" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// flag the row
}];
flagAction.backgroundColor = [UIColor yellowColor];
return @[moreAction, flagAction];
}
Run Code Online (Sandbox Code Playgroud)
注意:使用高分辨率图像以使其适用
iPhone 6 Plus 736x414 points 5.5"
iPhone 6 667x375 points 4.7"
iPhone 5 568x320 points 4.0"
iPhone 4 480x320 points 3.5"
Run Code Online (Sandbox Code Playgroud)
这个链接上有用的帖子http://pablin.org/
| 归档时间: |
|
| 查看次数: |
8735 次 |
| 最近记录: |