UIButton标签不会出现在UIImageView上
问题描述:
我用户界面生成器来定位叠加UIButton和UIImageView。 在代码中,更改按钮标签,如果存在图像UIButton标签不会出现在UIImageView上
在example.h文件
@property (strong, nonatomic) IBOutlet UIButton *takePicture;
@property (strong, nonatomic) IBOutlet UIImageView *image;
在Example.m
[self.image setImage:aPhoto];
(...)
NSString *pictureButtonTitle = [email protected]"Changer la photo":@"Ajouter une photo";
(...)
[self.takePicture setTitle:pictureButtonTitle forState:UIControlStateNormal];
我使用此代码为一个视图,我看“当myCondition为true时,在我的图片上正确更改图片“。 但在另一种观点,没有出现!为什么?
答
你既可以做到在界面生成器 - 为你做,或做在您的viewDidLoad方法:
- (void)viewDidLoad {
[super viewDidLoad];
[self.view bringSubviewToFront:self.button];
}
排号网点在IB,你也意味着较低的对象将是其他人的顶部......当按钮放置在屏幕截图中所示的所有其他对象的下方时,该按钮将位于“顶部”/顶部。
如果你想以不同的方式安排的网点,你可以用这些方法,以及:
[self.view insertSubview:self.button aboveSubview:self.imageView];
或者:
[self.view insertSubview:self.imageView belowSubview:self.button];
答
好吧,我发现:在界面生成器,它似乎是为了你把你的对象如果放置的UIButton之前的UIImageView重要
,它工作得很好。
我看到标签
但是,如果你正好相反:按钮是像下。
和标签不显示
我仍然不知道这是否是重新安排这些项目的唯一途径?
谢谢你,我喜欢你的方式! – 2015-04-03 12:07:56