这就是我所做的:
@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 来使用它,因为我认为它是最优雅的解决方案。我似乎不能这样做。
特别是,我在问为什么我的方法(例如,用于更改搜索控制器的背景)不适用于此。