0

私は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でフルサイズで表示されているのに対し、iPhone4より下のiOSデバイスは正しく表示されていることです。TTLauncherViewライブラリに変更を加える必要があるのか​​、それともそのような問題を解決するためのより簡単な方法があるのか​​、疑問に思っています。

4

2 に答える 2

2

これは、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;
}

...そしてこれは更新されたバージョンです...

- (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;
}

おそらくそこには、丸みを帯びた画像の角のような必要のないものがあります。有効な部分は、画像サイズを64x64にロックするTTImageStyleディレクティブです。お役に立てれば。

于 2011-03-22T10:29:19.377 に答える
1

Three20のTTLauncherViewを使用しています

代わりに、SDWebImageを使用してみてください。

https://github.com/rs/SDWebImage

UIImageViewに2つのロードを発行できます。1つは高解像度画像用、もう1つは低解像度画像用です。低解像度が最初に終了する必要があります...

于 2011-03-21T05:26:28.610 に答える