Snapkit: Can't set contentCompressionResistanceHorizontalPriority

Created on 22 Dec 2017  路  2Comments  路  Source: SnapKit/SnapKit

New Issue Checklist

  • [x] I have looked at the Documentation
  • [x] I have read the F.A.Q.
  • [x] I have filled out this issue template.

Issue Info

Info | Value |
-------------------------|-------------------------------------|
Platform | iOS
Platform Version | iOS 11 (but I think this happens on any version)
SnapKit Version | 4.0.0
Integration Method | cocoapods

Issue Description

I can't set contentCompressionResistanceHorizontalPriority on a view.

self.lblTitle.snp.contentCompressionResistanceHorizontalPriority = UILayoutPriority.defaultLow.rawValue

it says: "Cannot assign to property: 'snp' is a get-only property"
I understand that I can't set it directly but there is no compression property inside the makeConstraints block.

shouldn't it be something like this:

self.lblTitle.snp.makeConstraints { make in
    make.contentCompressionResistanceHorizontalPriority.equalTo(UILayoutPriority.defaultLow)
}

Thanks
Giorgi

Most helpful comment

Just set the priority on the view itself using vanilla UIKit

lblTitle.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)

All 2 comments

Just set the priority on the view itself using vanilla UIKit

lblTitle.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)

@Rendel27 @rnystrom is correct here, I chose not to re-implement the vanilla functions here. SnapKit also does not have any additional shortcuts for setting layout margins or safe area margins.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swiftli picture swiftli  路  9Comments

mkoppanen picture mkoppanen  路  3Comments

semiwhale picture semiwhale  路  3Comments

danieleggert picture danieleggert  路  3Comments

cjwirth picture cjwirth  路  4Comments