我正在使用Three20的TTLauncherView,我想知道是否有人有过加载高分辨率图像的经验?
http://three20.info/showcase/launcher
我正在使用以下方法来设置我的TTLauncherItem:
NSString *imageUrl = [self displayImageUrl:@"http://foo.com/lowres.png" withHighResUrl:@"http://foo.com/hires.png";
TTLauncherItem *launcherItem = [[[TTLauncherItem alloc] initWithTitle:@"Icon1"
image:imageUrl
URL:@"Icon1"
canDelete:NO] autorelease];这是我用来确定它是否是iOS4的方法。
- (NSString *)displayImageUrl:(NSString *)standardResUrl withHighResUrl:(NSString *)highResUrl {
NSString *imageUrl = nil;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2) {
imageUrl = highResUrl;
} else {
imageUrl = standardResUrl;
}
return imageUrl;
}问题是,图像实际上是在iPhone 4上以全尺寸显示,而iPhone 4以下的任何iOS设备都能正常显示。我想知道我是否需要对TTLauncherView库进行更改,或者是否有更简单的方法来解决这样的问题。
发布于 2011-03-22 18:29:19
为此,我在基于launcherButtonImage的three20样式表中添加了一个新样式。这是原始的..。
- (TTStyle*)launcherButtonImage:(UIControlState)state {
TTStyle* style =
[TTBoxStyle styleWithMargin:UIEdgeInsetsMake(-7, 0, 11, 0) next:
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:8] next:
[TTImageStyle styleWithImageURL:nil defaultImage:nil contentMode:UIViewContentModeCenter
size:CGSizeZero next:nil]]];
if (state == UIControlStateHighlighted || state == UIControlStateSelected) {
[style addStyle:
[TTBlendStyle styleWithBlend:kCGBlendModeSourceAtop next:
[TTSolidFillStyle styleWithColor:RGBACOLOR(0,0,0,0.5) next:nil]]];
}
return style;
}...and这是更新后的版本...
- (TTStyle*)favoriteLauncherButtonImage:(UIControlState)state {
TTStyle* style =
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape
shapeWithRadius:4.0] next:
[TTBoxStyle styleWithMargin:UIEdgeInsetsMake(0, 0, 0, 0)
padding:UIEdgeInsetsMake(16, 16, 16, 16)
minSize:CGSizeMake(0, 0)
position:TTPositionStatic next:
[TTImageStyle styleWithImageURL:nil defaultImage:nil contentMode:UIViewContentModeScaleAspectFit
size:CGSizeMake(64, 64) next: nil
]]];
if (state == UIControlStateHighlighted || state == UIControlStateSelected) {
[style addStyle:
[TTBlendStyle styleWithBlend:kCGBlendModeSourceAtop next:
[TTSolidFillStyle styleWithColor:RGBACOLOR(0,0,0,0.5) next:nil]]];
}
return style;
}里面可能有一些你不需要的东西,比如圆角图像。执行部分是TTImageStyle指令,它将图像大小锁定为64x64。希望这能有所帮助。
发布于 2011-03-21 13:26:29
我使用的是Three20的TTLauncherView
相反,尝试使用SDWebImage:
https://github.com/rs/SDWebImage
您可以在UIImageView上执行两个加载,一个用于高分辨率图像,另一个用于低分辨率图像。低分辨率的应该第一个完成...
https://stackoverflow.com/questions/5374091
复制相似问题