如果应用程序在视网膜 4 设备上运行,我将使用此UIImage
类别自动查找正确的资产:http:
//www.sourcedrop.net/FY53a14b0127f
如果在子类的方法中实例化,它会正确找到带有-568h@2x
后缀的资产:UIImage
UIView
init
-(id) init{
self = [super init];
if(self){
myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton setImage:[UIImage imageNamed:@"go_back_image"] forState:UIControlStateNormal];
[self addSubview:myButton];
}
}
但是如果UIImage
在类中实例化了,didMoveToSuperView
则该类别不会获取资产:
-(void)didMoveToSuperview{
if(self.superview != nil){
[myButton setImage:[UIImage imageNamed:@"otherImage"] forState:UIControlStateNormal];
[myButton setImage:[UIImage imageNamed:@"otherImageHighlighted"] forState:UIControlStateHighlighted];
}
}
如果在其中UIImage
创建,didMoveToSuperview
则显示正常大小的资产...
有什么想法吗?