gsdios / SDAutoLayout

One line of code to implement automatic layout. 一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于做最简单易用的AutoLayout库。The most easy way for autoLayout. Based on runtime.
MIT License
5.9k stars 1.28k forks source link

UILabel类设置约束失效,其他类没问题,排查了很久都没找到问题在哪 #320

Closed CodeWii closed 4 years ago

CodeWii commented 5 years ago

测试发现,必须设置 setSingleLineAutoResizeWithMaxWidth 布局才会生效,多行依然失效,不知道跟什么冲突了

CodeWii commented 5 years ago
UILabel *test = [[UILabel alloc]init];
test.backgroundColor = KPRandomColor;
[self.view addSubview:test];

test.sd_layout.leftSpaceToView(self.view, 30).topSpaceToView(self.view, 100).widthIs(100).heightIs(30);

我这样写,视图上完全找不到控件。

CodeWii commented 5 years ago

找到问题了,搜了UILabel分类,有个文件用了runtime修改了width,其实刚开始就看到了这个文件,记得当时注释了还是不行,现在还是这里的问题,果然还是要一点点排查问题。接手前人代码,处处是坑。

MimiOuO commented 4 years ago

老哥 同样的问题,谢谢Thanks♪(・ω・)ノ

bolee commented 4 years ago

如果只有一个控件时候要调用这个setSingleLineAutoResizeWithMaxWidth才能生效