#import "ImageEx.h"
//ImageExの実装
@implementation ImageEx
//初期化
- (id)initWithFrame:(CGRect)frame {
if (self=[super initWithFrame:frame]) {
//背景色の指定
self.backgroundColor=[UIColor whiteColor];
//イメージの読み込み
_image=[[UIImage imageNamed:@"sample.png"] retain];
}
return self;
}
//描画
- (void)drawRect:(CGRect)rect {
//イメージの描画
[_image drawAtPoint:CGPointMake(0,0)];
//イメージの拡大縮小描画
[_image drawInRect:CGRectMake(0,160,
_image.size.width*2,_image.size.height*2)];
}
//メモリの解放
- (void)dealloc {
//イメージの解放
[_image release];
//メモリの解放
[super dealloc];
}
@end |