visual-format-language

“Width equals height” constraint using visual format language

半腔热情 提交于 2019-12-24 07:46:30
问题 In order to add width equals to its superview height we can do following NSLayoutConstraint(item: view, attribute: .width, relatedBy: .equal, toItem: view.superview, attribute: .height, multiplier: 1, constant: 0) or we can do it from interface builder But how can I do the same using VFL? 回答1: From the documentation of Auto Layout Guide: Visual Format Language The notation prefers good visualization over completeness of expressibility. Most of the constraints that are useful in real user

Manage UITextField's dynamic position using auto layout

 ̄綄美尐妖づ 提交于 2019-12-24 05:47:06
问题 My client’s requirement is as follows: I am going to create registration form with around 15 textFields(Pre defined on server). Information of fields in registration fields are coming from server. There are chances that some fields are not required in some cases. So, I will get fields which are required for that particular case. E.g. Suppose No. of predefined fields are 15 on server. i.e. FirstName, LastName, Phone no., Date of Birth, Picture, Email,Address,zipcode etc. But there are chances

Using Autolayout Visual Format with Swift?

寵の児 提交于 2019-12-20 09:47:19
问题 I've been trying to use the Autolayout Visual Format Language in Swift, using NSLayoutConstraint.constraintsWithVisualFormat . Here's an example of some code that does nothing useful, but as far as I can tell should make the type checker happy: let foo:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat( format: "", options: 0, metrics: {}, views: {}) However, this triggers the compiler error: "Cannot convert the expression's type '[AnyObject]!' to type 'String!'". Before I assume

NSLayoutConstraint style for VFL

♀尐吖头ヾ 提交于 2019-12-13 08:08:52
问题 "V:|[v(>=height)]-0.0@highPriority-|" What will be the constraint (NSLayoutConstraint style) for above VFL. Perhaps its considering view height with greaterThanEqual & bottom constraint with UILayoutPriority.defaultHigh . Something i used - let heightConstraint = NSLayoutConstraint(item: self.view!, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.greaterThanOrEqual, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 0) let bottomConstraint =

Objective C Visual Autolayout NSTextField dynamic height

六眼飞鱼酱① 提交于 2019-12-12 09:25:26
问题 I am trying to create a dynamic size NSView using visual auto layout. I am trying to achieve something like the following diagram. I added following constraints to achieve this. [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-15-[_iconImageView(39)]-12-[_textView(239)]-15-|" options:NSLayoutFormatAlignAllTop metrics:nil views:views]]; [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-15-[_textView]-4-[_mainButton]-5-|" options:

Autolayout not working and warnings

和自甴很熟 提交于 2019-12-11 20:43:57
问题 I am trying to add a button just above the bottom of my view. I am adding the autolayout constraints programatically, and here is my code. - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"height : %f", self.view.bounds.size.height); [self.view addConstraints: [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=topSpace)-[button1]" options:0 metrics:@{@"topSpace":@(self.view.bounds.size.height*0.9f)} views:@{@"button1" : self.button1}]]; // Do any additional setup after loading the view

Using Autolayout Visual Format with Swift?

谁都会走 提交于 2019-12-02 18:51:57
I've been trying to use the Autolayout Visual Format Language in Swift , using NSLayoutConstraint.constraintsWithVisualFormat . Here's an example of some code that does nothing useful, but as far as I can tell should make the type checker happy: let foo:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat( format: "", options: 0, metrics: {}, views: {}) However, this triggers the compiler error: "Cannot convert the expression's type '[AnyObject]!' to type 'String!'". Before I assume this is a Radar-worthy bug, is there anything obvious I'm missing here? This happens even without the

iOS8 Auto layout programatically pin to relative layout margin

荒凉一梦 提交于 2019-11-30 18:29:37
I have an UI element ( UISwitch actually, but does not matter really) that has both leading and trailing space pinned to superview in Interface Builder. The constraint looks like this in Xcode 6: The constraint for leading space is the same effectively. The value of constraint is 42.0 points . This is exactly what I want, because for different devices I can change layoutMargins property on UIView and the constraints will work correctly, to increase margin between views. Now I want to add another view in code that would also have both leading and trailing space pinned to it's superview margin,

Swift Safe Area Layout Guide and Visual Format Language

我是研究僧i 提交于 2019-11-30 11:03:22
I want to use Apples visual format language to constrain a view to the new Safe Area Layout Guide in iOS 11. However, I get an exception: -[NSLayoutYAxisAnchor nsli_superitem]: unrecognized selector sent to instance 0x1c447ed40 //Make View Dictionary var views: [String: Any] = ["left": self.leftContainer] //Check swift version and add appropriate piece to the view dictionary if #available(iOS 11, *) { views["topGuide"] = self.view.safeAreaLayoutGuide.topAnchor }else{ views["topGuide"] = self.topLayoutGuide } //Make the constraint using visual format language let leftVertical =

iOS8 Auto layout programmatically pin to relative layout margin

倖福魔咒の 提交于 2019-11-30 02:40:30
问题 I have an UI element ( UISwitch actually, but does not matter really) that has both leading and trailing space pinned to superview in Interface Builder. The constraint looks like this in Xcode 6: The constraint for leading space is the same effectively. The value of constraint is 42.0 points . This is exactly what I want, because for different devices I can change layoutMargins property on UIView and the constraints will work correctly, to increase margin between views. Now I want to add