NSString *path = @"http://*******/************/**.jpg"; // URL
NSURL* url = [NSURL URLWithString:path];
NSData* data = [NSData dataWithContentsOfURL:url];
photo = [[UIImageView alloc] initWithImage:[[UIImage alloc] initWithData:data]];
[self.view photo];
2010年12月1日水曜日
UIImage でURL の画像を表示する。
ラベル:
iPhone,
UIImage,
UIImageView
2010年9月17日金曜日
Day6 Reaction Time(2)view に背景画像を追加する
背景画像として、road.png をview に追加する。
road.png をResources フォルダに追加して、以下のように実装した。
参考にしたのは以下の箇所。
参考サイト:
User Experiense Coding How-To's
road.png をResources フォルダに追加して、以下のように実装した。
- (void)viewDidLoad {
[super viewDidLoad];
UIImage* backgroundImage = [UIImage imageNamed:@"road.png"];
UIImageView* backgroundView = [[UIImageView alloc] initWithImage:backgroundImage];
[backgroundView setFrame:[[UIScreen mainScreen] bounds]];
[self.view addSubview:backgroundView];
[backgroundView release];
}
参考にしたのは以下の箇所。
How do I create a view for images?さらに、UIImageView を setFrame メソッドで画面全体に表示させて、view に追加している。
To create a view for images, use the UIImageView class, as shown in Listing 14.
Listing 14: Creating a view for images
UIImage *image = [UIImage imageNamed:@"image.png"];
UIImageView *theImageView = [[UIImageView alloc] initWithImage:image];
参考サイト:
User Experiense Coding How-To's
ラベル:
iPhone,
tutorial,
UIImage,
UIImageView
2010年9月1日水曜日
Day 2 画像をアニメーション表示させる
UIImageViewクラスを利用して画像をアニメーション表示させる。
viewDidLoadに以下で実装した処理を追加する。
実装手順は以下の通り。
1.
animationImagesプロパティに、アニメーションで使われる画像を格納した配列を指定する。最後に nil を入れるのを忘れない。
2.
アニメーションの設定を下記のプロパティで指定する。
animationDurationプロパティで、アニメーションの時間を指定する。
animationRepeatCountプロパティで、アニメーションを繰り返す回数を指定する。
3.
startAnimatingメソッドで、アニメーションを開始する。
4.
現在のviewにUIImageViewを追加する。
viewDidLoadに以下で実装した処理を追加する。
実装手順は以下の通り。
1.
animationImagesプロパティに、アニメーションで使われる画像を格納した配列を指定する。最後に nil を入れるのを忘れない。
2.
アニメーションの設定を下記のプロパティで指定する。
animationDurationプロパティで、アニメーションの時間を指定する。
animationRepeatCountプロパティで、アニメーションを繰り返す回数を指定する。
3.
startAnimatingメソッドで、アニメーションを開始する。
4.
現在のviewにUIImageViewを追加する。
ラベル:
iPhone,
tutorial,
UIImageView
登録:
投稿 (Atom)