UITabBarController相關(guān)知識(shí)

UITabBarItem的相關(guān)屬性

<pre>
// 通過(guò)appearance統(tǒng)一設(shè)置所有UITabBarItem的文字屬性
// 后面帶有UI_APPEARANCE_SELECTOR的方法, 都可以通過(guò)appearance對(duì)象來(lái)統(tǒng)一設(shè)置
UITabBarItem *item=[UITabBarItem appearance];
//設(shè)置tabaritem的正常情況下的屬性
NSMutableDictionary *textArr=[NSMutableDictionary dictionary];
textArr[NSForegroundColorAttributeName]=[UIColor redColor];//文字顏色
[item setTitleTextAttributes:textArr forState:UIControlStateNormal];
</pre>

設(shè)置UITabBarItem的圖片和文字title

<pre>
//設(shè)置文字
childVc.tabBarItem.title=title;
// 設(shè)置子控制器的圖片
childVc.tabBarItem.image = [UIImage imageNamed:image];
// //使用指定渲染模式---總是繪制原始圖像,而不將它視為模板(搞掉系統(tǒng)默認(rèn))
childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
</pre>

UITabBarController代理
1.是否允許選擇不同item觸發(fā)后續(xù)操作,YES 允許,NO不允許

<pre>

  • (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
    {
    NSLog(@"hello");
    return YES;
    }
    </pre>
2.每次點(diǎn)擊tabBarItem后觸發(fā)這個(gè)方法(只有點(diǎn)擊標(biāo)簽欄中的五個(gè)按鈕才會(huì)觸發(fā),MORE里邊的不會(huì)觸發(fā))

<pre>

  • (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
    {

    NSLog(@"%@!",viewController.title);
    }
    </pre>

3.當(dāng)點(diǎn)擊moreNaviegationController中的編輯按鈕時(shí)觸發(fā)的方法

<pre>

  • (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers
    {
    NSLog(@"biaji");
    }
    </pre>
4.當(dāng)點(diǎn)擊完成按鈕的時(shí)候,觸發(fā)此方法

<pre>
//changed : 標(biāo)記viewController的順序是否改變
//ViewControllers 返回最新的tabBarController中viewControllers

  • (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed NS_AVAILABLE_IOS(3_0)
    {
    if(changed)
    {
    NSLog(@"change@");
    }
    else
    {
    NSLog(@"not change");
    }

    for(UIViewController *vc in viewControllers)
    {
    NSLog(@"%@",vc.title);
    }
    }
    </pre>

常用的事件UIControlState

UIControlStateNormal 正常狀態(tài)
UIControlStateHighlighted 高亮狀態(tài)
UIControlStateDisabled 不可點(diǎn)擊狀態(tài)
UIControlStateSelected 選中狀態(tài)

常見的屬性及說(shuō)明(富文本屬性)

NSFontAttributeName 字體

NSParagraphStyleAttributeName 段落格式

NSForegroundColorAttributeName 字體顏色

NSBackgroundColorAttributeName 背景顏色

NSStrikethroughStyleAttributeName 刪除線格式

NSUnderlineStyleAttributeName 下劃線格式

NSStrokeColorAttributeName 刪除線顏色

NSStrokeWidthAttributeName 刪除線寬度

NSShadowAttributeName 陰影

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容