How to edit UIAlertAction text font size and color

后端 未结 7 922
时光取名叫无心
时光取名叫无心 2020-12-06 01:33

How to edit UIAlertAction text size and color? I have taken a UIAlertController acoording to it how to edit the size. This i smy Code



        
7条回答
  •  忘掉有多难
    2020-12-06 01:39

    Use NSMutableAttributedString set the font size and color, use this below code,

    UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"Do you wish to logout?" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    
    NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"Do you wish to logout?"];
    
    [hogan addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:50.0] range:NSMakeRange(24, 11)];
    
    [hogan addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,35)];
    
    [controller setValue:hogan forKey:@"attributedTitle"];
    
    UIAlertAction *logOut = [UIAlertAction actionWithTitle:@"Log Out" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {}];
    

    hope its helpful

提交回复
热议问题