@@ -31,9 +31,9 @@ -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStri
31
31
/* *
32
32
* 您可以尝试用不同的布局来实现相同的功能。
33
33
*/
34
- // [self createLinearRootLayout];
35
- [self createRelativeRootLayout ];
36
- // [self createFloatRootLayout];
34
+ // [self createLinearRootLayout];
35
+ // [self createRelativeRootLayout];
36
+ [self createFloatRootLayout ];
37
37
}
38
38
39
39
return self;
@@ -116,6 +116,7 @@ -(void)createLinearRootLayout
116
116
// 这个设置的意思是_nameLabel的宽可以动态增长,但是不能超过父视图的宽度,并且要保证后面的2个图片视图显示出来。
117
117
// 您可以通过uBound方法设置尺寸的最大上边界。具体参见对uBound的方法的详细介绍。
118
118
_nameLabel.widthSize .equalTo (_nameLabel.widthSize ).uBound (userNameLayout.widthSize , -(5 + 14 + 5 + 14 ), 1 );
119
+ _nameLabel.heightSize .equalTo (@25 );
119
120
[userNameLayout addSubview: _nameLabel];
120
121
121
122
UIImageView *editImageView = [[UIImageView alloc ] initWithImage: [UIImage imageNamed: @" edit" ]];
@@ -143,6 +144,7 @@ -(void)createLinearRootLayout
143
144
_priceLabel.adjustsFontSizeToFitWidth = YES ;
144
145
// 宽度最宽为100,注意到这里使用了宏MYDIMESCALEW表示会根据屏幕的宽度来对100进行缩放。这个100是按iPhone6为标准设置的。具体请参考MyDimeScale类。
145
146
_priceLabel.widthSize .equalTo (_priceLabel.widthSize ).uBound (@(MYDIMESCALEW (100 )), 0 , 1 ).lBound (@(MYDIMESCALEW (50 )), 0 , 1 );
147
+ _priceLabel.heightSize .equalTo (@25 );
146
148
_priceLabel.myLeading = 10 ;
147
149
[rootLayout addSubview: _priceLabel];
148
150
@@ -180,13 +182,15 @@ -(void)createRelativeRootLayout
180
182
_priceLabel.centerYPos .equalTo (rootLayout.centerYPos );
181
183
// priceLabel的宽度根据内容自适应,但是最大的宽度是100,最小的宽度是50。注意到这里使用了宏MYDIMESCALEW表示会根据屏幕的宽度来对100进行缩放。这个100是在DEMO中是按iPhone6为标准设置的。具体请参考MyDimeScale类的介绍。
182
184
_priceLabel.widthSize .equalTo (_priceLabel.widthSize ).uBound (@(MYDIMESCALEW (100 )), 0 , 1 ).lBound (@(MYDIMESCALEW (50 )), 0 , 1 );
185
+ _priceLabel.heightSize .equalTo (@25 );
183
186
[rootLayout addSubview: _priceLabel];
184
187
185
188
186
189
_nameLabel = [UILabel new ];
187
190
_nameLabel.font = [CFTool font: 17 ];
188
191
_nameLabel.textColor = [CFTool color: 3 ];
189
- _nameLabel.wrapContentWidth = YES ; // 视图的宽度由内容包裹
192
+ _nameLabel.widthSize .equalTo (_nameLabel.widthSize ); // 视图的宽度由内容包裹
193
+ _nameLabel.heightSize .equalTo (@25 );
190
194
_nameLabel.leadingPos .equalTo (_headImageView.trailingPos );
191
195
// 1.3.0版本最新支持。设置_nameLabel的右边距最大是_priceLabel的左边距,再偏移两个小图标和间距的距离。这样当_nameLabel的尺寸超过这个最大的右边距时就会自动的缩小视图的宽度。
192
196
_nameLabel.trailingPos .uBound (_priceLabel.leadingPos , (5 + 14 + 5 + 14 ));
@@ -269,6 +273,7 @@ -(void)createFloatRootLayout
269
273
// 这个设置的意思是_nameLabel的宽可以动态增长,但是不能超过父视图的宽度,并且要保证后面的2个图片视图显示出来。
270
274
// 您可以通过uBound方法设置尺寸的最大上边界。具体参见对uBound的方法的详细介绍。
271
275
_nameLabel.widthSize .equalTo (_nameLabel.widthSize ).uBound (userInfoLayout.widthSize , -(5 + 14 + 5 + 14 ), 1 );
276
+ _nameLabel.heightSize .equalTo (@25 );
272
277
[userInfoLayout addSubview: _nameLabel];
273
278
274
279
UIImageView *editImageView = [[UIImageView alloc ] initWithImage: [UIImage imageNamed: @" edit" ]];
0 commit comments