答案 0 :(得分:1)
答案 1 :(得分:0)
As you are not using the storyboard, Below code will help you in setting the frame of label:-
UILabel *labelName;//This will be your label instance
CGFloat yAxis = 50;//This will be your image view's y axis + image view's height
[labelName setFrame:CGRectMake(0, yAxis, self.view.frame.size.width, self.view.frame.size.height)];
//Set the color/Font other properties of label as desired
[labelName setTextAlignment:NSTextAlignmentCenter];
答案 2 :(得分:0)
设置约束是有效的解决方案。
要么你可以按照Mr.UB建议的故事板方式,要么按照代码的方式进行处理。如果你想通过代码继续,我建议你使用Masonry来设置约束。
你可以这样做:
[your-label mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(imgView.mas_top); //with is an optional semantic filler
make.mas_centerX.equalTo(imgView.mas_centerX);
}];