1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| @implementation UIAlertAction (ZDExtension)
- (void)zd_setTitleColor:(UIColor *)color { [self setValue:color forKey:@"titleTextColor"]; }
@end
@implementation UIAlertController (ZDExtension)
- (void)zd_setTitleColor:(UIColor *)color { NSAttributedString *string = [[NSAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17],NSForegroundColorAttributeName:color}]; [self zd_setAttributedTitle:string]; }
- (void)zd_setAttributedTitle:(NSAttributedString *)title { [self setValue:title forKey:@"attributedTitle"]; }
- (void)zd_setMessageColor:(UIColor *)color { NSAttributedString *string = [[NSAttributedString alloc] initWithString:self.message attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:color}]; [self zd_setAttributedMessage:string]; }
- (void)zd_setAttributedMessage:(NSAttributedString *)message { [self setValue:message forKey:@"attributedMessage"]; }
- (void)zd_setActionTitleColor:(UIColor *)color { for (UIAlertAction *action in self.actions) { [action zd_setTitleColor:color]; } }
@end
|