设为首页 加入收藏

TOP

iOS开发中标签控制器的使用——UITabBarController(二)
2015-12-15 23:09:10 来源: 作者: 【 】 浏览:9
Tags:iOS 开发 标签 控制器 使用 UITabBarController
;
//是否透明效果
@property(nonatomic,getter=isTranslucent) BOOL translucent;
?
?2、UITabBarDelegate


//选中标签时调用
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item;
//将要开始编辑标签时
- (void)tabBar:(UITabBar *)tabBar willBeginCustomizingItems:(NSArray *)items;? ? ? ? ? //已经开始编辑标签时? ? ? ?
- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray *)items;? ? ? ? ?
//将要进入编辑状态时
- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray *)items changed:(BOOL)changed;
//已经进入编辑状态时
- (void)tabBar:(UITabBar *)tabBar didEndCustomizingItems:(NSArray *)items changed:(BOOL)changed;
?
五、再看UITabBarItem


和NavigationItem类似,标签栏上的item也可以自定义,一些方法如下。


初始化方法:


//通过标题和图案进行创建
- (instancetype)initWithTitle:(nullable NSString *)title image:(nullable UIImage *)image tag:(NSInteger)tag;
- (instancetype)initWithTitle:(nullable NSString *)title image:(nullable UIImage *)image selectedImage:(nullable UIImage *)selectedImage;
//创建系统类型的
- (instancetype)initWithTabBarSystemItem:(UITabBarSystemItem)systemItem tag:(NSInteger)tag;
?


UITabBarSystemItem的枚举如下:


typedef NS_ENUM(NSInteger, UITabBarSystemItem) {
? ? UITabBarSystemItemMore,//更多图标
? ? UITabBarSystemItemFavorites,//最爱图标
? ? UITabBarSystemItemFeatured,//特征图标
? ? UITabBarSystemItemTopRated,//高级图标
? ? UITabBarSystemItemRecents,//最近图标
? ? UITabBarSystemItemContacts,//联系人图标
? ? UITabBarSystemItemHistory,//历史图标
? ? UITabBarSystemItemBookmarks,//图书图标
? ? UITabBarSystemItemSearch,//查找图标
? ? UITabBarSystemItemDownloads,//下载图标
? ? UITabBarSystemItemMostRecent,//记录图标
? ? UITabBarSystemItemMostViewed,//全部查看图标
};


UITabBarItem常用属性:


//设置选中图案
@property(nullable, nonatomic,strong) UIImage *selectedImage;


下面这个属性可以设置item的头标文字:


con.tabBarItem.badgeva lue = @"1";



?
//设置标题的位置偏移
@property (nonatomic, readwrite, assign) UIOffset titlePositionAdjustment;


由于UITabBarItem是继承于UIBarItem,还有下面这个属性可以设置使用:


//标题
@property(nullable, nonatomic,copy)? ? ? ? ? ? NSString? ? *title;?
//图案? ?
@property(nullable, nonatomic,strong)? ? ? ? ? UIImage? ? *image;?
//横屏时的图案? ? ?
@property(nullable, nonatomic,strong)? ? ? ? ? UIImage? ? *landscapeImagePhone;
//图案位置偏移
@property(nonatomic)? ? ? ? ? ? ? ? ? UIEdgeInsets imageInsets;
//横屏时的图案位置偏移
@property(nonatomic)? ? ? ? ? ? ? ? ? UIEdgeInsets landscapeImagePhoneInsets ;
//设置和获取标题的字体属性
- (void)setTitleTextAttributes:(nullable NSDictionary *)attributes forState:(UIControlState)state;
- (nullable NSDictionary *)titleTextAttributesForState:(UIControlState)state;


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇iOS9新特性——堆叠视图UIStackVi.. 下一篇iOS自定义的emoji表情键盘

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: