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 陰影