alert 文字顏色

  UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"輸入暱稱" message:nil preferredStyle:UIAlertControllerStyleAlert];app

    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){string

        textField.placeholder = @"暱稱";it

    }];io

    //改變TintColor的顏色table

    [[UIView appearance]setTintColor:[UIColor colorWithRed:11/255.0 green:175/255.0 blue:200/255.0 alpha:1]];im

 

    UIAlertAction * phoneAction = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){dict

        

        UITextField * textFi = [alertController.textFields firstObject];tab

        NSLog(@"保存  %@",textFi.text);animate

    }];di

    

    UIAlertAction * cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];

//    [[UIView appearance]setBackgroundColor:[UIColor lightGrayColor]];

//    phoneAction.

 

    // 改變標題的顏色

    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"輸入暱稱"];

    NSRange strRange = {0,[str length]};

    

    [str addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];

    

    //設置背景顏色以及下劃線

    NSDictionary * dict1 = @{

                             NSForegroundColorAttributeName:[UIColor colorWithRed:254/255.0 green:152/255.0 blue:1/255.0 alpha:1],

                             NSUnderlineStyleAttributeName:@"0"};

    

    //從下標14開始,長度爲6的內容添加多個屬性,dict1裏面寫的就是添加的屬性

    [str addAttributes:dict1 range:strRange];

    //改變標題

//    NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"輸入暱稱"];

//  

//    [hogan addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, [[hogan string] length])];

    [alertController setValue:str forKey:@"attributedTitle"];

    

    [alertController addAction:phoneAction];

    [alertController addAction:cancleAction];

    [self presentViewController:alertController animated:YES completion:nil];

相關文章
相關標籤/搜索