layoutSubviews和layoutSubviews

參考: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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章