我可以通过UIAppearance代理设置哪些属性?

Emi*_*ier 75 iphone uikit ios ios5 ios6

我可以通过UIAppearance代理设置哪些属性?Apple的UIKit文档没有列出它们.有这些属性的列表吗?

Emi*_*ier 210

可以通过UIAppearance设置的属性UI_APPEARANCE_SELECTOR在相应的头文件中标记.

要生成标记为的属性列表UI_APPEARANCE_SELECTOR,可以在终端中使用以下unix命令:

cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer??/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers
grep -H UI_APPEARANCE_SELECTOR ./* | sed 's/ __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0) UI_APPEARANCE_SELECTOR;//'
Run Code Online (Sandbox Code Playgroud)

这是我使用上面的命令编译的列表.这适用于5.0 SDK.为简洁起见,省略了相应的getter方法.


UIActivityIndi​​catorView

@property (readwrite, nonatomic, retain) UIColor *color
Run Code Online (Sandbox Code Playgroud)

的UIBarButtonItem

@property(nonatomic,retain) UIColor *tintColor
- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics
- (void)setBackgroundVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics 
- (void)setTitlePositionAdjustment:(UIOffset)adjustment forBarMetrics:(UIBarMetrics)barMetrics 
- (void)setBackButtonBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics
- (void)setBackButtonTitlePositionAdjustment:(UIOffset)adjustment forBarMetrics:(UIBarMetrics)barMetrics
- (void)setBackButtonBackgroundVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics 

[iOS 6.0]
- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state style:(UIBarButtonItemStyle)style barMetrics:(UIBarMetrics)barMetrics [iOS 6.0]
Run Code Online (Sandbox Code Playgroud)

UIBarItem

- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state
Run Code Online (Sandbox Code Playgroud)

UINavigationBar的

@property(nonatomic,retain) UIColor *tintColor
@property(nonatomic,copy) NSDictionary *titleTextAttributes
- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics
- (void)setTitleVerticalPositionAdjustment:(CGFloat)adjustment forBarMetrics:(UIBarMetrics)barMetrics

[iOS 6.0]
@property(nonatomic,retain) UIImage *shadowImage

[iOS 7.0]
@property(nonatomic,retain) UIColor *barTintColor 
- (void)setBackgroundImage:(UIImage *)backgroundImage forBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics 
- (UIImage *)backgroundImageForBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics 
@property(nonatomic,retain) UIImage *backIndicatorImage 
@property(nonatomic,retain) UIImage *backIndicatorTransitionMaskImage 
Run Code Online (Sandbox Code Playgroud)

UIPageControl

[iOS 6.0]
@property(nonatomic,retain) UIColor *pageIndicatorTintColor
@property(nonatomic,retain) UIColor *currentPageIndicatorTintColor
Run Code Online (Sandbox Code Playgroud)

UIProgressView

@property(nonatomic, retain) UIColor* progressTintColor    
@property(nonatomic, retain) UIColor* trackTintColor    
@property(nonatomic, retain) UIImage* progressImage
@property(nonatomic, retain) UIImage* trackImage
Run Code Online (Sandbox Code Playgroud)

UIRefreshControl

[iOS 6.0]
@property (nonatomic, retain) UIColor *tintColor
@property (nonatomic, retain) NSAttributedString *attributedTitle
Run Code Online (Sandbox Code Playgroud)

的UISearchBar

@property(nonatomic,retain) UIImage *backgroundImage
@property(nonatomic,retain) UIImage *scopeBarBackgroundImage
@property(nonatomic) UIOffset searchFieldBackgroundPositionAdjustment
@property(nonatomic) UIOffset searchTextPositionAdjustment
- (void)setSearchFieldBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state
- (void)setImage:(UIImage *)iconImage forSearchBarIcon:(UISearchBarIcon)icon state:(UIControlState)state
- (void)setScopeBarButtonBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state 
- (void)setScopeBarButtonDividerImage:(UIImage *)dividerImage forLeftSegmentState:(UIControlState)leftState rightSegmentState:(UIControlState)rightState
- (void)setScopeBarButtonTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state
- (void)setPositionAdjustment:(UIOffset)adjustment forSearchBarIcon:(UISearchBarIcon)icon

[iOS 7.0]
@property(nonatomic,retain) UIColor *barTintColor 
- (void)setBackgroundImage:(UIImage *)backgroundImage forBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics 
- (UIImage *)backgroundImageForBarPosition:(UIBarPosition)barPosition barMetrics:(UIBarMetrics)barMetrics 
Run Code Online (Sandbox Code Playgroud)

UISegmentedControl

@property(nonatomic,retain) UIColor *tintColor UI_APPEARANCE_SELECTOR;
- (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics 
- (void)setDividerImage:(UIImage *)dividerImage forLeftSegmentState:(UIControlState)leftState rightSegmentState:(UIControlState)rightState barMetrics:(UIBarMetrics)barMetrics
- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state
- (void)setContentPositionAdjustment:(UIOffset)adjustment forSegmentType:(UISegmentedControlSegment)leftCenterRightOrAlone barMetrics:(UIBarMetrics)barMetrics
Run Code Online (Sandbox Code Playgroud)

UISlider

@property(nonatomic,retain) UIColor *minimumTrackTintColor
@property(nonatomic,retain) UIColor *maximumTrackTintColor
@property(nonatomic,retain) UIColor *thumbTintColor
Run Code Online (Sandbox Code Playgroud)

UIStepper

[iOS 6.0]
@property(nonatomic,retain) UIColor *tintColor
- (void)setBackgroundImage:(UIImage*)image forState:(UIControlState)state
- (void)setDividerImage:(UIImage*)image forLeftSegmentState:(UIControlState)leftState rightSegmentState:(UIControlState)rightState
- (void)setIncrementImage:(UIImage *)image forState:(UIControlState)state
- (void)setDecrementImage:(UIImage *)image forState:(UIControlState)state
Run Code Online (Sandbox Code Playgroud)

UISwitch

@property(nonatomic, retain) UIColor* onTintColor

[iOS 6.0]
@property(nonatomic, retain) UIColor *tintColor
@property(nonatomic, retain) UIColor *thumbTintColor
@property(nonatomic, retain) UIImage *onImage
@property(nonatomic, retain) UIImage *offImage
Run Code Online (Sandbox Code Playgroud)

UITabBar

@property(nonatomic,retain) UIColor *tintColor
@property(nonatomic,retain) UIColor *selectedImageTintColor
@property(nonatomic,retain) UIImage *backgroundImage
@property(nonatomic,retain) UIImage *selectionIndicatorImage

[iOS 6.0]
@property(nonatomic,retain) UIImage *shadowImage

[iOS 7.0]
@property(nonatomic,retain) UIColor *barTintColor 
@property(nonatomic) UITabBarItemPositioning itemPositioning 
@property(nonatomic) CGFloat itemWidth 
@property(nonatomic) CGFloat itemSpacing 
@property(nonatomic) UIBarStyle barStyle 
Run Code Online (Sandbox Code Playgroud)

UITabBarItem

- (void)setTitlePositionAdjustment:(UIOffset)adjustment
Run Code Online (Sandbox Code Playgroud)

UITableView的

[iOS 6.0]
@property(nonatomic, retain) UIColor *sectionIndexColor
@property(nonatomic, retain) UIColor *sectionIndexTrackingBackgroundColor

[iOS 7.0]
@property (nonatomic) UIEdgeInsets separatorInset 
@property(nonatomic, retain) UIColor *sectionIndexBackgroundColor 
Run Code Online (Sandbox Code Playgroud)

的UITableViewCell

[iOS 7.0]
@property (nonatomic) UIEdgeInsets separatorInset 
Run Code Online (Sandbox Code Playgroud)

UITableViewHeaderFooterView

[iOS 6.0]
@property(nonatomic, retain) UIColor *tintColor
Run Code Online (Sandbox Code Playgroud)

UIToolbar

@property(nonatomic,retain) UIColor *tintColor;
- (void)setBackgroundImage:(UIImage *)backgroundImage forToolbarPosition:(UIToolbarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics

[iOS 6.0]
- (void)setShadowImage:(UIImage *)shadowImage forToolbarPosition:(UIToolbarPosition)topOrBottom

[iOS 7.0]
@property(nonatomic,retain) UIColor *barTintColor 
Run Code Online (Sandbox Code Playgroud)

(2012年7月3日):此列表直到最新版本的XCode(4.3.3)才更改.


(2013年3月12日):针对SDK 6.1更新了列表.适用于iOS 6.0(或更高版本)的属性列在[iOS 6.0]标记下.


(2013年10月24日):针对SDK 7.0更新了列表.适用于iOS 7.0(或更高版本)的属性列在[iOS 7.0]标记下.

  • 我很惊讶`UIButton`没有任何'UI_APPEARANCE_SELECTOR`属性,但符合`UIAppearance`协议.这是Apple的疏忽吗? (14认同)
  • 我找不到这样的清单.UI_APPEARANCE_SELECTOR宏似乎不是整个故事,因为UIView.h不使用它(至少5.0),但下面的代码可以工作:[[UIView appearance] setBackgroundColor:[UIColor redColor]]; (3认同)
  • 使用App Store Xcode和iOS 5.1,标题路径现在是:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.框架/头 (2认同)
  • 使用`xcode-select --print-path`获取Developer目录的路径. (2认同)