參考:Custom UIImage Subclass To Support @2x Retina Devices
-(id)initWithContentsOfFile:(NSString *)path
{
if([UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0 )
{
NSString *path2x = [[path stringByDeletingLastPathComponent]
stringByAppendingPathComponent:
[NSString stringWithFormat:@"%@@2x.%@",
[[path lastPathComponent] stringByDeletingPathExtension],
[path pathExtension]]];
if ([[NSFileManager defaultManager] fileExistsAtPath:path2x])
return [super initWithContentsOfFile:path2x];
}
return [super initWithContentsOfFile:path];
}
沒有留言:
張貼留言
歡迎大家留言提問,我會答的都會盡力回答!
如果太久沒出現回應就是我又忘記回來看留言了TAT