分析UIBarItem UITabBarItem
UIBarItem 是UITabBarItem的基类
//UIBarItem.h
//
// UIBarItem.h
// UIKit
//
// Copyright (c) 2008-2013, Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIGeometry.h>
#import <UIKit/UIKitDefines.h>
#import <UIKit/UIAppearance.h>
#import <UIKit/UIControl.h>
@class UIImage;
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIBarItem : NSObject <UIAppearance> {
@private
}
@property(nonatomic,getter=isEnabled) BOOL enabled; // default is YES 是否可用
@property(nonatomic,copy) NSString *title; // default is nil 标题
@property(nonatomic,retain) UIImage *image; // default is nil 图片
@property(nonatomic,retain) UIImage *landscapeImagePhone NS_AVAILABLE_IOS(5_0); // default is nil
@property(nonatomic) UIEdgeInsets imageInsets; // default is UIEdgeInsetsZero 图片缩进
@property(nonatomic) UIEdgeInsets landscapeImagePhoneInsets NS_AVAILABLE_IOS(5_0); // default is UIEdgeInsetsZero. These insets apply only when the landscapeImagePhone property is set. andscapeImagePhone 边缘缩进
@property(nonatomic) NSInteger tag; // default is 0 标志
/* You may specify the font, text color, and shadow properties for the title in the text attributes dictionary, using the keys found in NSAttributedString.h.
*/
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (NSDictionary *)titleTextAttributesForState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
@end
2.UITabBarItem 介绍
typedef NS_ENUM(NSInteger, UITabBarSystemItem) { //枚举
UITabBarSystemItemMore, //更多类型
UITabBarSystemItemFavorites, //喜爱
UITabBarSystemItemFeatured, 特性
UITabBarSystemItemTopRated, 排行
UITabBarSystemItemRecents, 最近
UITabBarSystemItemContacts, 联系人
UITabBarSystemItemHistory, 历史
UITabBarSystemItemBookmarks, 书签
UITabBarSystemItemSearch, 搜索
UITabBarSystemItemDownloads, 下载
UITabBarSystemItemMostRecent,
UITabBarSystemItemMostViewed,
};
@class UIView, UIImage;
NS_CLASS_AVAILABLE_IOS(2_0) @interface UITabBarItem : UIBarItem {
@private
NSString *_title;
SEL _action;
id _target;
UIImage *_templateImage;
UIImage *_selectedTemplateImage;
UIImage *_selectedImage;
UIImage *_unselectedImage;
UIEdgeInsets _imageInsets;
NSString *_badgeValue;
UIView *_view;
NSInteger _tag;
id _appearanceStorage;
struct {
unsigned int enabled:1;
unsigned int style:3;
unsigned int isSystemItem:1;
unsigned int systemItem:7;
unsigned int viewIsCustom:1;
unsigned int animatedBadge:1;
unsigned int customSelectedImage:1;
unsigned int customUnselectedImage:1;
} _tabBarItemFlags;
}
/* The unselected image is autogenerated from the image argument. The selected image
is autogenerated from the selectedImage if provided and the image argument otherwise.
To prevent system coloring, provide images with UIImageRenderingModeAlwaysOriginal (see UIImage.h)
*/
- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag;
- (instancetype)initWithTitle:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage NS_AVAILABLE_IOS(7_0);
- (id)initWithTabBarSystemItem:(UITabBarSystemItem)systemItem tag:(NSInteger)tag;
@property(nonatomic,retain) UIImage *selectedImage NS_AVAILABLE_IOS(7_0);
@property(nonatomic,copy) NSString *badgeValue; // default is nil
/* These methods are now deprecated. Please use -initWithTitle:image:selectedImage:.
*/
- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage NS_DEPRECATED_IOS(5_0,7_0,"Use initWithTitle:image:selectedImage: or the image and selectedImage properties along with UIImageRenderingModeAlwaysOriginal");
- (UIImage *)finishedSelectedImage NS_DEPRECATED_IOS(5_0,7_0);
- (UIImage *)finishedUnselectedImage NS_DEPRECATED_IOS(5_0,7_0);
/* To set item label text attributes use the appearance selectors available on the superclass, UIBarItem.
Use the following to tweak the relative position of the label within the tab button (for handling visual centering corrections if needed because of custom text attributes)
*/
- (void)setTitlePositionAdjustment:(UIOffset)adjustment NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
- (UIOffset)titlePositionAdjustment NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
@end