UITableViewRowAction's
以下のように、ソースコードに3つあります。
- (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
条件では無効として作成されます。
ただし、のみが有効で他の 2 つが無効な 場合、 の は他の 2 つbackgroundColor
にmessageAction
影響します。messageAction
これを確認するために、最初に配置することでボタンの表示順序を逆にしましたcancelAction
。そうすれば、キャンセル ボタンbackgroundColor
は他の 2 つに影響します。
backgroundColor
各ボタンの視覚化 od プロパティを修正するにはどうすればよいですか?