stefanrenne / constraintlib Goto Github PK
View Code? Open in Web Editor NEWSwift library that simplifies interacting with Xcode Constraints
License: Apache License 2.0
Swift library that simplifies interacting with Xcode Constraints
License: Apache License 2.0
Hi, I am experimenting some unexpected behaviour with .pin
function, I am not sure if I missed something.
I have the code snippet bellow. However, my fonts is being added but it is not visible.
label = UILabel()
label.text = textLabel
label.textAlignment = .center
label.textColor = UIColor.green
label.font = UIFont(name: fontName, size: self.bounds.height)
label.adjustsFontSizeToFitWidth = true
label.baselineAdjustment = .alignCenters
self.addSubview(label)
label.pin([.top, .left, .width, .height])
Then, when I changed the Constraints to the native one, it shows up.
label = UILabel()
label.text = textLabel
label.textAlignment = .center
label.textColor = UIColor.green
label.font = UIFont(name: fontName, size: self.bounds.height)
label.translatesAutoresizingMaskIntoConstraints = false
label.adjustsFontSizeToFitWidth = true
label.baselineAdjustment = .alignCenters
self.addSubview(label)
// label.pin([.top, .left, .width, .height])
NSLayoutConstraint(
item: label,
attribute: .top,
relatedBy: .equal,
toItem: self,
attribute: .top,
multiplier: 1.0,
constant: 0
).isActive = true
NSLayoutConstraint(
item: label,
attribute: .left,
relatedBy: .equal,
toItem: self,
attribute: .left,
multiplier: 1.0,
constant: 0
).isActive = true
NSLayoutConstraint(
item: label,
attribute: .height,
relatedBy: .equal,
toItem: self,
attribute: .height,
multiplier: 1.0,
constant: 0
).isActive = true
NSLayoutConstraint(
item: label,
attribute: .width,
relatedBy: .equal,
toItem: self,
attribute: .width,
multiplier: 1.0,
constant: 0
).isActive = true
I am trying to use self.topLayoutGuide
to position my widget. But I can't compile. It says
/Users/eduardoj/Qwantech/Blupper_Iphone/Blupper/Blupper/BlupRevealVC.swift:28:21: Type of expression is ambiguous without more context
Here is my code:
let newView = UIView()
mainStack.addSubview(newView)
newView.pin([.top: self.topLayoutGuide, .left:0.0, .height:100.0, .width:100.0])
newView.backgroundColor = UIColor.red
I already tried:
newView.pin([.top: self.topLayoutGuide.length, .left:0.0, .height:100.0, .width:100.0])
and
newView.pin([.topTo(self.topLayoutGuide): 0, .left:0.0, .height:100.0, .width:100.0])
but didn't work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.