Snapkit是一个AutoLayout的封装库,是Masonary在Swift中的代替品。通过SnapKit,我们可以方便的进行UI的操作。
苹果提供AutoLayout方便了UI设计,但是官方提供的Api极度蛋疼, 为了一个四边相等,我们需要书写如下数据:
?xml version="1.0" encoding="UTF-8"?
```Swift
marqueeLabel.leftAnchor.constraint(equalTo: leftAnchor, constant: 0).isActive = true
marqueeLabel.rightAnchor.constraint(equalTo: rightAnchor, constant: 0).isActive = true
marqueeLabel.topAnchor.constraint(equalTo: topAnchor, constant: 0).isActive = true
marqueeLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0).isActive = true
```
网友评论