iOS布局

时间:2021-09-29 11:52:33

1.Masonry 创建constraint来定义布局的方式:
1.1、 mas_makeConstraints :
你可以使用局部变量后者属性来保存以便下次应用它
1.2、 mas_updateConstraints: adding/updating
有时候你需哟啊更新constraint,而不是创建固定的constraint
1.3、 mas_remakeConstraints:
都是跟新constraint,不过,它是删除之前constraint,然后再添加新的
constraint;

iOS布局

2. Classy 是一个能与UIkit无缝结合stylesheet系统,借鉴与css思想,但引入新的语法和命名规则
2.1、 {}:
$main-color = #e1e1e1;
MyCustomView{
background-color:$main-color;
titile-insets:5,10,5,10;
>UIProgressView.tinted{
progress-tint-color:black;
track-tint-color:yellow;
}

}
^UIButton.warning, UIView.warning ^UIButton{
title-color[state:highlighted]:#e3e3e3;
}

2.2 默认样式:Classy在应用程序Bundle默认查找文件名为stylesheet.cas的样式文件。

3. Live Reload:Live Reload是实时显示编写UI代码效果的关键特性,他能够实时检查stylesheet
文件变化,无需重新编译、构建和运行模拟器,从而极大提高开发速度
3.1 Style Selecotors 是指定那个View使用那种样式的方式
3.1.1 Object Class
3.1.2 View Hierarchy
3.1.3 Style Class

3.2 Properties:Classy支持所有UIAppearance的属性和方法,也支持与UIAppearance无关的
很多属性。Classy使用与UIKit相同属性命名

4. Keep it DRY
4.1 Classy提供三种方式避免代码重复:grouping,nesting,variables