Abd*_*bdu 2 cocoa-touch uitableview ios ios11
我收到一条日志消息
[TableView]不再支持将图案颜色设置为UITableViewRowAction的backgroundColor.
在iOS 11之前,图案颜色工作正常.
我的项目使用自定义表格视图,向左滑动以执行操作,在行动作背景颜色中,我使用100x100图像.
例如:
editAction.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LeaveRequest_Eng.png"]];
Run Code Online (Sandbox Code Playgroud)
我无法完全显示该图像; 图像被拉伸,并没有填满所有区域.
我相信苹果鼓励/强迫你现在使用新的UIContextualActionapi.以前许多开发人员会使用colorWithPatternImage:添加图像,UITableViewRowAction这些图像总是有些破解和脆弱.从iOS 11开始,现在有一种支持的方法,通过实现以下方式将行图像添加到行动作:- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView
trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath.例如:
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView
trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath {
UIContextualAction *editAction = [UIContextualAction contextualActionWithStyle:UIControlStateNormal title:@"Edit" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
NSLog(@"Do editing");
completionHandler(YES);
}];
editAction.image = [UIImage imageNamed:@"MyEditImage"];
editAction.backgroundColor = [UIColor blueColor];
return [UISwipeActionsConfiguration configurationWithActions:@[editAction]];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1224 次 |
| 最近记录: |