创建一个UIView的子类,在- (void)drawRect:(CGRect)rect中写入
[self setBackgroundColor:[UIColor clearColor]]; UIImage *img = [UIImage imageNamed:@"game_top.png"]; [img drawAsPatternInRect:rect];并在- (id)initWithFrame:(CGRect)frame中写入
self = [super initWithFrame:frame]; if (self) { [self drawRect:frame]; } return self;在调用的地方直接调用- (id)initWithFrame:(CGRect)frame即可。
?