参考:http://www.tuicool.com/articles/qIb2qe
- (void)createTableView
{
view = [[MYView alloc]init];
view.frame = CGRectMake(0, 0, 10, 10);
[self.view addSubview:view];//开始调用drawRect
UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
bt.frame = CGRectMake(20, 100, 100, 100);
[bt addTarget:self action:@selector(aa) forControlEvents:UIControlEventTouchUpInside];
bt.backgroundColor = [UIColor redColor];
[self.view addSubview:bt];
// _sendGoodsTV = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) style:UITableViewStyleGrouped];
// _sendGoodsTV.delegate = self;
// _sendGoodsTV.dataSource = self;
// _sendGoodsTV.backgroundColor = lightGrayBGColor;
// _sendGoodsTV.separatorStyle = UITableViewCellSeparatorStyleNone;
// [self.view addSubview:_sendGoodsTV];
}
- (void)aa
{
view.frame = CGRectMake(100, 200, 20, 20);
}
@implementation MYView
-(void)setNeedsLayout
{
}
- (void)layoutSubviews
{
}
- (void)drawRect:(CGRect)rect
{
}
@end