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

推荐答案

可以通过UI外观设置的属性在相应的头文件中标记为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;//'

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


UIActivityIndicatorView

@property (readwrite, nonatomic, retain) UIColor *color

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]

UIBarItem

- (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state

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 

UIPageControl

[iOS 6.0]
@property(nonatomic,retain) UIColor *pageIndicatorTintColor
@property(nonatomic,retain) UIColor *currentPageIndicatorTintColor

UIProgressView

@property(nonatomic, retain) UIColor* progressTintColor    
@property(nonatomic, retain) UIColor* trackTintColor    
@property(nonatomic, retain) UIImage* progressImage
@property(nonatomic, retain) UIImage* trackImage

UIRefreshControl

[iOS 6.0]
@property (nonatomic, retain) UIColor *tintColor
@property (nonatomic, retain) NSAttributedString *attributedTitle

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 

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

UISlider

@property(nonatomic,retain) UIColor *minimumTrackTintColor
@property(nonatomic,retain) UIColor *maximumTrackTintColor
@property(nonatomic,retain) UIColor *thumbTintColor

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

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

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 

UITabBarItem

- (void)setTitlePositionAdjustment:(UIOffset)adjustment

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 

UITableViewCell

[iOS 7.0]
@property (nonatomic) UIEdgeInsets separatorInset 

UITableViewHeaderFooterView

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

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 

(July 3, 2012):此列表在XCode的最新版本(4.3.3)之前没有更改.


(March 12, 2013):SDK 6.1更新了列表.适用于IOS 6.0(或更高版本)的属性列在[iOS 6.0]标记下.


(Oct. 24, 2013):SDK 7.0更新列表.适用于IOS 7.0(或更高版本)的属性列在[iOS 7.0]标记下.

Ios相关问答推荐

flutter中实现自定义底部导航栏

当应用程序被杀死时是否还能获取位置?

确保方法调配的安全有效实施

如何使用 Rxswift 处理程序最喜欢的按钮

iOS上从谷歌云存储API不断收到网络连接已丢失的错误信息

uikit中如何触发swiftui功能

Swift/iOS:泛型错误:协议需要嵌套类型V;你想添加它吗?

SwiftUI 中的描边图像边框

如何解码没有名称的 JSON 数组?

通过函数使用 Gesture 时,键入任何视图不能符合视图

如何根据设备时间设置 Flutter 应用时间线?

将值传递给导航链接视图中的文本框

SwiftUI 文本字段代理绑定代码忽略空格不起作用?

检测 iPhone 应用程序中是否存在摄像头?

在 Swift 中执行 while 循环

如何在 Swift 3 中根据 UIImage 的大小/比率调整 UIImageView 的大小?

Xcode 故事板:内部错误.请提交错误

在 React Native 中保存敏感数据

如何用 CAShapeLayer 和 UIBezierPath 画一个光滑的圆?

在转发类对象中找不到属性