Skip to content

Commit cc757c8

Browse files
committed
Update README.md
1 parent 95715c8 commit cc757c8

1 file changed

Lines changed: 31 additions & 7 deletions

File tree

README.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,37 @@
22
致力于做最简单易用的Autolayout库。The most easy way for autolayout.
33

44
# 摒弃复杂累赘的约束,利用运行时Runtime在合适的时机布局视图。
5+
6+
7+
# ☆新增:label文字自适应 + cell高度自适应☆
8+
9+
>> UILabel文字自适应:
10+
// autoHeightRatio() 传0则根据文字自动计算高度(传大于0的值则根据此数值设置高度和宽度的比值)
11+
_label.sd_layout.autoHeightRatio(0);
12+
13+
>> Cellg高度自适应:
14+
// cell布局设置好之后调用此方法就可以实现高度自适应(注意:如果用高度自适应则不要再以cell的底边为参照去布局其子view)
15+
[self setupAutoHeightWithBottomView:_view4 bottomMargin:10];
16+
17+
设置tableview数据源和代理
18+
19+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
20+
{
21+
// >>>>>>>>>>>>>>>>>>>>> * cell自适应步骤1 * >>>>>>>>>>>>>>>>>>>>>>>>
22+
[self.tableView startAutoCellHeightWithCellClass:“cell类名” contentViewWidth:“contentview宽度”];
23+
24+
return _rowCount;
25+
}
26+
27+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
28+
{
29+
// >>>>>>>>>>>>>>>>>>>>> * cell自适应步骤2 * >>>>>>>>>>>>>>>>>>>>>>>>
30+
return [self.tableView cellHeightForIndexPath:indexPath model:“model” keyPath:@"model属性名"];
31+
}
32+
33+
34+
# ****************普通view的自动布局***************
35+
536
# 0.用法示例
637
/* 用法一 */
738
_view.sd_layout
@@ -13,13 +44,6 @@
1344
/* 用法二 (一行代码搞定,其实用法一也是一行代码) */
1445
_view.sd_layout.leftSpaceToView(self.view, 10).topSpaceToView(self.view,80).heightIs(130).widthRatioToView(self.view, 0.4);
1546

16-
# ☆新增:label文字自适应 + cell高度自适应☆
17-
// autoHeightRatio() 传0则根据文字自动计算高度(传大于0的值则根据此数值设置高度和宽度的比值)
18-
_label.sd_layout.autoHeightRatio(0);
19-
20-
// cell布局设置好之后调用此方法就可以实现高度自适应(注意:如果用高度自适应则不要再以cell的底边为参照去布局其子view)
21-
[self setupAutoHeightWithBottomView:_view4 bottomMargin:10];
22-
2347
*******************************************************************************
2448
2549
注意:先把需要自动布局的view加入父view然后在进行自动布局,例:

0 commit comments

Comments
 (0)