4
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.

technerd
  • 12,929
  • 9
  • 56
  • 82
席小雨
  • 63
  • 3
  • What do you want to do and what is your problem? What have you tried to solve it yourself? – Tali Sep 06 '16 at 08:06

3 Answers3

6

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()
}
Clint Lin
  • 94
  • 1
2

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.

Jakub
  • 12,851
  • 13
  • 75
  • 130
0

You can also use SnapKit, which is the Swift only version of Masonry. It looks like they have decided not to deprecate Masonry, as was previously the case, but is still a good idea for your Swift only projects. If you are familiar with Masonry, you can migrate to SnapKit very easily.

Bill Burgess
  • 13,768
  • 6
  • 47
  • 85