XView.m

IVIS

Jump to: navigation, 찾기

[편집] XView.m


#import "Xview.h"


@implementation Xview
@synthesize img;
@synthesize btn;


- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
		img = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,100,100)];
		[img setImage:[UIImage imageNamed:@"벌.png"]];
		[self addSubview:img];
        
		btn = [[UIButton alloc] initWithFrame:CGRectMake(300, 400, 80, 30)];
		btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
		[btn setFrame:CGRectMake(100, 150, 100, 30)];
		[btn addTarget:self action:@selector(setNeedsDisplay) forControlEvents:UIControlEventTouchUpInside];
		[self addSubview:btn];
	}
    return self;
}


- (void)drawRect:(CGRect)rect {
	[img setFrame:CGRectMake(img.frame.origin.x + 10, img.frame.origin.y + 10, 100, 100)];
    // Drawing code
}


- (void)dealloc {
    [super dealloc];
}


@end