布局如下:
采用masonry適配, 只給了圖片的left 以及 centerY坐標(biāo),
self.titleImageV = [[UIImageView alloc] init];
[self.backImageV addSubview:self.titleImageV];
[self.titleImageV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(10);
make.centerY.mas_equalTo(self.backImageV.mas_centerY);
}];
然后運(yùn)行程序,發(fā)現(xiàn)圖片沒(méi)問(wèn)題,還原原有的尺寸,之后后面的label給left赴叹、right荆虱、以及centerY,
self.titleL = [[UILabel alloc] init];
self.titleL.textColor = [UIColor whiteColor];
self.titleL.font = [UIFont systemFontOfSize:13 * sHeight];
self.titleL.numberOfLines = 0;
[self.backImageV addSubview:self.titleL];
[self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleImageV.mas_right).offset(6 * sWidth);
make.right.mas_equalTo(-6 * sWidth);
make.centerY.mas_equalTo(self.backImageV.mas_centerY);
}];
結(jié)果發(fā)現(xiàn)圖片被拉伸了 ,
解決辦法 : 被拉伸的控件水平抗壓縮 如下代碼
[self.titleImageV setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];