UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(2, 2, 100, 100)]; btn.backgroundColor = [UIColor redColor]; btn.layer.cornerRadius = 3; UIView *view = [[UIView alloc]initWithFrame:CGRectMake(99, 99, 104, 104)]; view.backgroundColor = [UIColor blueColor]; view.layer.cornerRadius = 3; [self.view addSubview:view]; [view addSubview:btn];