【发布时间】:2015-02-23 08:05:13
【问题描述】:
我有一个UIButton 作为子视图添加到我的超级视图中,它只是一个大块,如何将图像添加到我的按钮。
- (void)viewDidLoad
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(890, 345 , 100, 100);
button.backgroundColor = [UIColor purpleColor];
[self.collectionView.superview addSubview:button];
[button addTarget:self action:@selector(changeContentOffset:) forControlEvents:UIControlEventTouchUpInside];
}
【问题讨论】:
-
[button addSubview:yourImageView]? -
你现在有很多答案。如果其中之一解决了您的问题,请接受。否则评论答案并询问更多信息/告诉您的问题或不兼容;)
-
RTFM!这个问题应该被否决。
标签: ios objective-c uibutton subview