iOS UIAlertController

1.添加一個(gè)輸入框

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"修改稅差(元/噸)" message:@"" preferredStyle:UIAlertControllerStyleAlert];
        //增加取消按鈕
        [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]];
        //增加確定按鈕
        [alertController addAction:[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            //獲取第1個(gè)輸入框夺欲;
            UITextField *TextField = alertController.textFields.firstObject;
            NSString *moneyStr = [NSString stringWithFormat:@"%.2lf",[TextField.text doubleValue]];
            if ([moneyStr doubleValue] >= [goods.salePrice doubleValue]) {
                kShowInfo(@"稅差不能大于等于含稅價(jià)格");
                return;
            }

            NSMutableDictionary * dict = [NSMutableDictionary dictionary];
            dict[@"goodsId"] = [GlobelConfig getNullStr:goods.ID];
            dict[@"taxPremium"] = moneyStr;
            [self changeTaxPremium:dict];
        }]];

        //定義第一個(gè)輸入框烟零;
        [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
            textField.placeholder = @"請(qǐng)輸入稅差";
            textField.keyboardType = UIKeyboardTypeDecimalPad;
            textField.text = [NSString stringWithFormat:@"%.2lf",[goods.taxPremium doubleValue]];
        }];

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

2.自定義UIAlertController的message

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:alertTitle message:@"" preferredStyle:UIAlertControllerStyleAlert];
    // 增加取消按鈕涝焙;
    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]];
    // 增加確定按鈕飘庄;
    [alertController addAction:[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (self.relatePlanOrderGoodsBlock) {
            self.relatePlanOrderGoodsBlock(selectArray);
            [self.navigationController popViewControllerAnimated:YES];
        }
    }]];
    
    NSMutableAttributedString * totalReportText = [GlobelConfig setTextColor:[NSString stringWithFormat:@"報(bào)款總金額:¥%.2f\n",totalReportAmount] chooseText:[NSString stringWithFormat:@"¥%.2f",totalReportAmount] color:[UIColor redColor] fontSize:16.0];
    NSMutableAttributedString * totalGoodsText = [GlobelConfig setTextColor:[NSString stringWithFormat:@"商品合計(jì)報(bào)款:¥%.2f\n",totalGoodsPaidAmount] chooseText:[NSString stringWithFormat:@"¥%.2f",totalGoodsPaidAmount] color:[UIColor redColor] fontSize:16.0];
    NSMutableAttributedString * totalFreightText = [GlobelConfig setTextColor:[NSString stringWithFormat:@"運(yùn)輸合計(jì)報(bào)款:¥%.2f\n",totalFreightPaidAmount] chooseText:[NSString stringWithFormat:@"¥%.2f",totalFreightPaidAmount] color:[UIColor redColor] fontSize:16.0];
    NSMutableAttributedString * totalInterestText = [GlobelConfig setTextColor:[NSString stringWithFormat:@"利息合計(jì)報(bào)款:¥%.2f\n",totalInterestPaidAmount] chooseText:[NSString stringWithFormat:@"¥%.2f",totalInterestPaidAmount] color:[UIColor redColor] fontSize:16.0];
    NSMutableAttributedString * residueUsableText = [GlobelConfig setTextColor:[NSString stringWithFormat:@"剩余可用金額:¥%.2f\n確定繼續(xù)嗎抒倚?",residueUsablePrice] chooseText:[NSString stringWithFormat:@"¥%.2f",residueUsablePrice] color:[UIColor redColor] fontSize:16.0];
    
    NSMutableAttributedString * endString = [[NSMutableAttributedString alloc]init];
    [endString appendAttributedString:totalReportText];
    [endString appendAttributedString:totalGoodsText];
    [endString appendAttributedString:totalFreightText];
    [endString appendAttributedString:totalInterestText];
    [endString appendAttributedString:residueUsableText];
    
    [alertController setValue:endString forKey:@"attributedMessage"];
   
    [self presentViewController:alertController animated:true completion:nil];

3.自定義UIAlertController的title

 [alert setValue:attibuedString forKey:@"attributedTitle"];

4.修改action字體的顏色(需要runtime與KVC結(jié)合使用)

// 修改字體的顏色
[nan setValue:[UIColor yellowColor] forKey:@"_titleTextColor"];
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末凡橱,一起剝皮案震驚了整個(gè)濱河市规阀,隨后出現(xiàn)的幾起案子挣跋,更是在濱河造成了極大的恐慌萍诱,老刑警劉巖悬嗓,帶你破解...
    沈念sama閱讀 219,039評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異裕坊,居然都是意外死亡包竹,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,426評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門籍凝,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)周瞎,“玉大人,你說(shuō)我怎么就攤上這事饵蒂∩睿” “怎么了?”我有些...
    開(kāi)封第一講書人閱讀 165,417評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵退盯,是天一觀的道長(zhǎng)彼乌。 經(jīng)常有香客問(wèn)我泻肯,道長(zhǎng),這世上最難降的妖魔是什么慰照? 我笑而不...
    開(kāi)封第一講書人閱讀 58,868評(píng)論 1 295
  • 正文 為了忘掉前任灶挟,我火速辦了婚禮,結(jié)果婚禮上毒租,老公的妹妹穿的比我還像新娘稚铣。我一直安慰自己,他們只是感情好墅垮,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,892評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布惕医。 她就那樣靜靜地躺著,像睡著了一般算色。 火紅的嫁衣襯著肌膚如雪曹锨。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 51,692評(píng)論 1 305
  • 那天剃允,我揣著相機(jī)與錄音沛简,去河邊找鬼。 笑死斥废,一個(gè)胖子當(dāng)著我的面吹牛椒楣,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播牡肉,決...
    沈念sama閱讀 40,416評(píng)論 3 419
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼捧灰,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了统锤?” 一聲冷哼從身側(cè)響起毛俏,我...
    開(kāi)封第一講書人閱讀 39,326評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎饲窿,沒(méi)想到半個(gè)月后煌寇,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,782評(píng)論 1 316
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡逾雄,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,957評(píng)論 3 337
  • 正文 我和宋清朗相戀三年阀溶,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片鸦泳。...
    茶點(diǎn)故事閱讀 40,102評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡银锻,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出做鹰,到底是詐尸還是另有隱情击纬,我是刑警寧澤,帶...
    沈念sama閱讀 35,790評(píng)論 5 346
  • 正文 年R本政府宣布钾麸,位于F島的核電站更振,受9級(jí)特大地震影響炕桨,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜殃饿,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,442評(píng)論 3 331
  • 文/蒙蒙 一谋作、第九天 我趴在偏房一處隱蔽的房頂上張望芋肠。 院中可真熱鬧乎芳,春花似錦、人聲如沸帖池。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,996評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)睡汹。三九已至肴甸,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間囚巴,已是汗流浹背原在。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 33,113評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留彤叉,地道東北人庶柿。 一個(gè)月前我還...
    沈念sama閱讀 48,332評(píng)論 3 373
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像秽浇,于是被迫代替她去往敵國(guó)和親浮庐。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,044評(píng)論 2 355