场景一:
// 自定义左滑显示编辑按钮
-(NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
title:@"跟进" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"跟进");
}];
UITableViewRowAction *rowActionSec = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault
title:@"快速备忘" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
NSLog(@"快速备忘");
}];
rowActionSec.backgroundColor = [UIColor colorWithHexString:@"f38202"];
rowAction.backgroundColor = [UIColor colorWithHexString:@"d9d9d9"];
NSArray *arr = @[rowAction,rowActionSec];
return arr;
}
场景二:
//开发中可能会有改变这个按钮背景色的需求,如微信的通讯录左滑备注按钮就是灰色的,实现这个需求我们需要自定义cell,在自定义的cell中重写layoutSubviews这个方法,找到UITableViewCellDeleteConfirmationView修改它的背景色即可。
#pragma mark - Encryption
- (NSData *)encryptedValue:(NSData *)value {
// Generate IV
NSData *iv = [SFCryptoUtils generateInitializationVector];
// Fetch encryption key
SFSecureStore *store = [SFSecureStore createUserStoreHandlerForScope:SFSecureStoreScopeLearning];
NSData *key = [store coreDataEncryptionKeyOfDataVault];
// Encrypt data
NSData *encryptedData = [SFCryptoUtils encryptDataWithIntegrityProtection:value withKey:key withInitializationVector:iv];
// Concatinate IV + SHA256 + encrypted data
NSMutableData *finalValue = [NSMutableData new];
[finalValue appendData:iv];
[finalValue appendData:encryptedData];
// Validate the sizes of these data objects haven't changed during development, throwing off decryption
NSAssert1(iv.length == LMS_IV_LENGTH, @"IV length is now %lu", (long unsigned)iv.length);
return [finalValue copy];
}
场景三:
//系统自带Cell 删除按钮样式修改:
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
return .delete
}
public override func layoutSubviews() {
super.layoutSubviews()
if let views = self.superview?.subviews {
for aView in views {
let viewName = NSStringFromClass(type(of: aView).self)
if viewName == "UISwipeActionPullView" {
aView.subviews.forEach { $0.backgroundColor = SSFTheme.Color.negativeLabel }
}
}
}
}