1
這是我做過什麼:子類UIActivityIndicator改變形象
@implementation BGUIActivityIndicator
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
[self customInitialize];
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
[self customInitialize];
return self;
}
-(void)customInitialize
{
UIView * theImageView= [self findASubViewforClass:[UIImageView class]];//
UIImageView * theImageView1 = (UIImageView *) theImageView;
theImageView1.image = [UIImage imageNamed:@"spinner_blue"];
[theImageView1.image saveScreenshot];
while (false) ;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
一切都顯得完美。 [theImageView1.image saveScreenshot];完美地記錄新舊觀點。
然而,沒有什麼變化。爲什麼?
我不完全問如何更改UIActivityIndicator的圖像。已經有很多了。我想通過繼承UIActivityIndicator來使用它,因爲我認爲這是最優雅的解決方案。我似乎無法做到這一點。
特別是,我在問爲什麼我的方法,例如改變搜索控制器的背景,不適用於此。