Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use masonry in swift 3.0

Tags:

swift3

masonry

Objective-C

[textView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.edges.mas_equalTo(UIEdgeInsetsZero).priorityLow();
    make.top.mas_equalTo(imageView.mas_bottom).offset(20);
}];

I want change swift code. please help me?? thanks.

like image 521
席小雨 Avatar asked Sep 06 '16 03:09

席小雨


2 Answers

These code make work

btn.mas_makeConstraints { (make:MASConstraintMaker?) in
    make?.top.equalTo()(view.mas_top)?.with().offset()(0)
    make?.left.equalTo()(view.mas_left)?.with().offset()(0)
    make?.right.equalTo()(view.mas_right)?.with().offset()(0)
    make?.bottom.equalTo()(view.mas_bottom)?.with().offset()(0)
    return()
}
like image 179
Clint Lin Avatar answered Sep 18 '22 22:09

Clint Lin


The shortest way to do it (if you want to mirror edges of parent view is)

    self.xibView .mas_makeConstraints( { make in
        _ = make?.edges.equalTo()(self)
    })

This assignment _ = also will silence the warning about un-assignment.

like image 20
Jakub Avatar answered Sep 17 '22 22:09

Jakub