我在我的源代碼3 UITableViewRowAction's
,象下面這樣:UITableViewRowAction - 酮的背景顏色影響其它
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView
editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(messagePremission)
{
messageAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"message_admin", nil), activity.GroupName] handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
}];
messageAction.backgroundColor = [UIColor colorWithRed:82.0/255.0 green:82.0/255.0 blue:82.0/255.0 alpha:1.0];
}
else
{
messageAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"message_admin", nil), activity.GroupName] handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
}];
messageAction.backgroundColor = [UIColor colorWithRed:200.0/255.0 green:199.0/255.0 blue:205.0/255.0 alpha:0.1];
}
if(editPermission)
{
editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:NSLocalizedString(@"edit_swipe", nil) handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
}];
editAction.backgroundColor = [UIColor colorWithRed:2.0/255.0 green:118.0/255.0 blue:246.0/255.0 alpha:1.0];
}
else
{
editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:NSLocalizedString(@"edit_swipe", nil) handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
}];
editAction.backgroundColor = [UIColor colorWithRed:2.0/255.0 green:118.0/255.0 blue:246.0/255.0 alpha:0.1];
}
if(cancelPermission)
{
cancelAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Cancel" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
}];
cancelAction.backgroundColor = [UIColor colorWithRed:251.0/255.0 green:1.0/255.0 blue:13.0/255.0 alpha:1.0];
}
else
{
cancelAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Cancel" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
}];
cancelAction.backgroundColor = [UIColor colorWithRed:251.0/255.0 green:1.0/255.0 blue:13.0/255.0 alpha:0.1];
}
[arrButtons addObject:messageAction];
[arrButtons addObject:editAction];
[arrButtons addObject:cancelAction];
return arrButtons;
}
在每種if
條件,按鈕被創建爲啓用,而在各自的else
條件,被禁用。
但是,messageAction
的backgroundColor
影響另外兩個時,只有啓用和其他兩個被禁用。
爲了確認這一點,我將cancelAction
作爲第一個來顛倒按鈕的顯示順序。這樣,取消按鈕的backgroundColor
影響了其他兩個。
如何修復每個按鈕的可視化屬性backgroundColor
屬性?
想要的行爲是什麼?它不清楚 – ddb
@ddb:期望的行爲是當他們沒有權限時,顯示禁用形式的按鈕(通過減少其背景)。 – Nitish
@ddb:但如果它只是一個對象,那麼如何顯示3個不同的按鈕? – Nitish