在我查看类中我有一些自定义外观属性( UIView
的子孙 ) 。 我想根据这些属性定制外观, 但我不能在初始化器中这样做, 因为使用 [[MyClass appress] setFoo:...]
设定的数值当时无效 :
@interface View : UIView
@property(strong) UIColor *someColor UI_APPEARANCE_SELECTOR;
@end
@implementation View
@synthesize someColor;
// Somewhere in other code before the initializer is called:
// [[View appearance] setSomeColor:[UIColor blackColor]];
- (id) initWithFrame: (CGRect) frame
{
self = [super initWithFrame:frame];
NSLog(@"%@", someColor); // nil
return self;
}
@end
它们已经设置在 layoutSubview
中, 但这不是执行视图定制的好点, 因为有些定制可能再次触发 layoutSubview
, 导致无尽循环 。
那么,什么是完成定制的好点? 还是有办法触发应用外观价值的代码?