Questions tagged [snapkit]

A Swift Autolayout DSL for iOS & macOS. Use if you have questions about the library and not about Snapchat or similar services.

SnapKit is a DSL to make Auto Layout easy on both iOS and macOS.

GitHub Page

208 questions
9
votes
2 answers

Snapkit: Constrain multiple to margins

I'm using Snapkit to simplify my autolayout code, however one scenario seems to popup very regularly, which i'm wondering if there's a way which involves less code. So let's say that I need to pin the edges of a UIView to it's superview margins, we…
TRG
  • 663
  • 1
  • 7
  • 17
9
votes
1 answer

Update SnapKit Constraint offset

I am using SnapKit and can't find a clean way to update the offset of a constraint. It's a simple loading bar view whose inner view (expiredTime) has to fill the parent (left to right) according to percentage. I create the constraint in the…
jalone
  • 1,823
  • 3
  • 27
  • 42
8
votes
3 answers

Swift - Difficulty with different sized images in TableViewCell

I am loading a number of remote images with Kingfisher and having significant difficulty getting them to load correctly into a Tableview with cells of dynamic heights. My goal is to have the images always be the full width of the screen and of a…
waffl
  • 4,140
  • 5
  • 60
  • 108
7
votes
1 answer

Warning : Unexpected version number in 'available' attribute for non-specific platform '*'

I have this snippet code : @available(*, deprecated:3.0, message:"Use activate().") public func install() { self.activate() } And since i've upgraded to swift5 and xcode 10.2 i get below warning : Unexpected version number in 'available'…
7
votes
3 answers

how to make UIView with equal width and height with SnapKit in Swift?

I want to make a UIView rectangular with SnapKit in Swift, like this lazy var customView: UIView = { let view = UIView(frame: CGRect()) self.addSubview(view) view.snp.makeConstraints({ (make) in …
Khoren Markosyan
  • 138
  • 1
  • 1
  • 6
6
votes
5 answers

How to update height Constraints by SnapKit and update cell height?

I have a TableViewCell and two button to switch different constrain. I want to update it's height constrain and cell height. like following pic1 when I click buttonB, the view will change like pic2 Then I click buttonA, the view will back to pic1 I…
JimmyLee
  • 397
  • 5
  • 17
5
votes
2 answers

Using snapkit / autolayout with UIScrollView

I have an app that will have a scrollView contentView chart buttons other stuff I tried constraining it like shown below, but I am missing a constraint and I can't find out what I need. self.view.addSubview(self.scrollView) …
Peter S
  • 487
  • 1
  • 4
  • 17
5
votes
2 answers

Constraint animation with SnapKit

I am trying to implement the animation of 2 views using SnapKit. Here is my Animation view: class MatchAnimation: UIView { let viewBackground: UIView = { let view = UIView() view.backgroundColor = UIColor(red: 0/255, green:…
Florian_L
  • 622
  • 9
  • 22
5
votes
1 answer

Recalculate SnapKit Constraint on orientation change

I want to recalculate the height constraint when the phone orientation changes. I'm using the functions uninstall() and install() to make this happen. However, it's not working as desired. Am I using them incorrectly? class…
mauryat
  • 1,540
  • 5
  • 27
  • 50
4
votes
1 answer

Using SnapKit to Aspect Ratio and less size

I am trying to create the constraints of this layout in SnapKit but I have difficulty setting the maximum size (lessThanOrEqual). let maxWidthContainer: CGFloat = 435 let maxHeightContainer: CGFloat = 600 containerView.snp.makeConstraints { …
rafaeldepaula
  • 126
  • 1
  • 9
4
votes
1 answer

iOS 11, Status bar, Navigation Bar and UIScrollview

I was making some updates to an app for iOS 11 and have run into something I cannot make sense of. My view controller creates all of its subviews programmatically. The first child is an Imageview. On top of that I add a UIScrollView. Within the…
E-Madd
  • 4,093
  • 5
  • 42
  • 72
4
votes
2 answers

Swift: How to get correct UICollectionView height when using snapkit?

I'm likely going about this in the completely wrong way since what I try to do should be simple... I have a view component which contains a few subviews, one of them being a UICollectionView. I layout the subviews using SnapKit. The UICollectionView…
jola
  • 735
  • 1
  • 8
  • 21
4
votes
1 answer

What advantages does SnapKit have over using autolayout in Interface Builder?

I've been using Interface Builder almost exclusively ever since Apple introduced autolayout for iOS. I recently came across SnapKit but I don't see any immediate advantage this has over using constraints in IB. The only thing it's got going for it…
Sid
  • 9,498
  • 5
  • 36
  • 59
4
votes
2 answers

Custom TableViewCell triggers NSLayoutConstraint error 'UIView-Encapsulated-Layout-Height'

I use Automatic Height for cells. And each time I want to update my cell with new data (model variable here) I updated my autolayout constraints and I get an error. Here just to show the issue, I don't even change the constraints. I simply ask to…
Mikael
  • 2,155
  • 1
  • 18
  • 42
4
votes
1 answer

Relative positioning using auto layout and SnapKit

I have a label which I want to have the same relative position on the screen, no matter what device is used. E.g. the label is positioned 10% off from the views top margin and 30% off from the views left margin. A constant will always do the…
Jake2Finn
  • 446
  • 3
  • 15
1
2 3
13 14