【发布时间】:2015-09-23 14:43:29
【问题描述】:
我正在尝试以编程方式在 UIImageView 的右上角创建一个 UIButton,到目前为止,我有一个 UIImageView,并且我想在图像加载到图像视图时在 UIImageView 的右上角创建一个 UIButton。我不知道我怎么能做到这一点。
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button setTitle:@"X" forState:UIControlStateNormal];
[button sizeToFit];
button.center = CGPointMake(self.img1.frame.origin.x+self.img1.frame.size.width,self.img1.bounds.origin.y);
[self.img1 addsubView : 按钮];
这里,img1 是一个图像视图。我想在 img1 的右上角添加那个按钮。
我怎样才能做到这一点?
【问题讨论】:
-
您的代码有什么问题?
-
不确定@Mr.T.它没有添加到 ImageView 的右上角,这就是我想要实现的。
-
查看调试视图层次结构以查看按钮的确切位置
标签: ios objective-c uiimageview uibutton