We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
感谢作者,在SnapKit中如何使用?能做个Demo吗?
The text was updated successfully, but these errors were encountered:
@tyzChar
其实很简单,就是在你觉得需要做适配的地方加上 ~ 就可以了
~
addButton.snp.makeConstraints { (make) in make.top.equalTo(tipLabel.snp.bottom).offset(20~) make.size.equalTo(CGSize(width: 150, height: 40)~) make.centerX.equalToSuperview() } licenceView.snp.makeConstraints { (make) in make.left.equalTo(15) make.right.equalTo(-15) make.top.equalTo(32~) make.height.equalTo(140~) }
如果适配的数值用于很多地方,建议可以按下面这种方式抽出来,再拿去使用
// MARK: Constants fileprivate struct Metric { static let bgInfoViewHeight = 100.f~ static let contentLeftRightMargin = 15.f }
bgInfoView.snp.makeConstraints { (make) in make.left.equalToSuperview().offset(Metric.contentLeftRightMargin) make.width.equalTo(Configs.Screen.width - 2*Metric.contentLeftRightMargin) make.top.equalToSuperview() make.height.equalTo(Metric.bgInfoViewHeight) }
支持以下几种类型也支持在后面加 ~ 和 ≈ 来做适配 ps: ≈ 可以按 option+x
≈
option+x
UIFont CGFloat CGPoint CGSize CGRect UIEdgeInsets
100~ UIFont.systemFont(ofSize: 14)~ CGPoint(x: 10, y: 10)~ CGRect(x: 10, y: 10, width: 100, height: 100)~ UIEdgeInsetsMake(10, 10, 10, 10)~
Sorry, something went wrong.
感谢
No branches or pull requests
感谢作者,在SnapKit中如何使用?能做个Demo吗?
The text was updated successfully, but these errors were encountered: