nslayoutconstraint

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 =

Autolayout & Alignment Constraints

萝らか妹 提交于 2019-12-13 05:14:57
问题 I want to make similar ui for all iPhones & i am currently using auto layout for that, but i do not know how to create this `UI` using `NSLayoutConstraint`? This UI works fine in small screen but i want same ui for bigger iPhone as well(keep certain amount of space between buttons). how can i add constraint in this to get same ui as iPhone 4s. i took UIButton & below titles are UILabel . Some one help me out here. Screenshots. 回答1: Personally I find that trying to make sense of Auto Layout

Animating a view created in IB using Autolayout

懵懂的女人 提交于 2019-12-13 04:10:08
问题 I have a view with a lot of labels and buttons which are created on code because in IB is too complicated. This works ok. In IB I also created an input view which I want to appear from the bottom by the tap on a button. Very much like a keyboard if you will. Because this input view is strigth forward, it has been created on IB and it contains sliders, labels, etc. I haven't added it as a subview of self.view on IB. By the tap of the button, I set up all the constrains for the input view: I

NSLayoutConstraint animation issue on iOS 10-11

懵懂的女人 提交于 2019-12-13 04:00:22
问题 I'm trying to implement show/hide animation for a view. The idea is to resize view's height constraint and to let its superview to resize with it. To achieve this I add view's height constraint and also pin its bottom constraint to superview's bottom (so I do not need specifying superview's height constraint) On iOS 9 it works as expected: And this happens on iOS 10-11: Animation code: #import "ViewController.h" @interface ViewController () { BOOL _hideFlag; CGFloat _redViewHeight; }

UITableView row height not changing

瘦欲@ 提交于 2019-12-13 03:46:54
问题 I have created a custom Cell. I have an array of dictionaries. For the dictionary values I need to create UILable s. Each cell may contained different number of UILabel s. So in my custom UITableViewCell class I have done like this. - (void)generateCell { BOOL isLandscape = UIInterfaceOrientationIsLandscape(vc.interfaceOrientation); for (int i = 0; i < [orderMap count]; i++) { UILabel *lbl = [[UILabel alloc] init]; [lbl setTextColor:[UIColor blueColor]]; [lbl setBackgroundColor:[UIColor

Conflicting constraints in iOS 7 UITableViewCell with AutoLayout

只愿长相守 提交于 2019-12-13 03:34:34
问题 Basically, I create an empty UITableViewCell in separate XIB file. Hierarchy is shown here: https://www.dropbox.com/s/nba8e5t7dvti7os/hierarchy.png I want to change height of my inner view at runtime based on content (by updating constraint constant) and based on this calculate cell/row height. So, if I have tall content, my row expands, if I have short content, my row becomes smaller. I want to use AutoLayout for these calculations. I have constraints to stick to top/bottom of ContentView

Get NSLayoutConstraint Identifier is not working for topAnchor

萝らか妹 提交于 2019-12-13 03:20:29
问题 I want to change TopAnchor Constraint of some View at runtime . Constraint Created: self.buttonHStack.topAnchor.constraint(equalTo: cellHStack.bottomAnchor , constant: 20).activate(withIdentifier: "topAnchor") Extension extension UIView { func getConstraint(withIndentifier indentifier: String) -> NSLayoutConstraint? { return self.constraints.filter { $0.identifier == indentifier }.first } } extension NSLayoutConstraint { func activate(withIdentifier identifier: String) { self.identifier =

How to pin Widths Equally to some UIViews with NSLayoutConstraint?

倖福魔咒の 提交于 2019-12-13 02:59:42
问题 How can I pin more than two UIViews with Widths Equally using NSLayoutConstraints? Right now, I'm using the following code and I can't pin more than two UIViews: for (int i = 0; i < column.count; i++) { NSString *horizontalFormat = @"H:|[view1][view2(==view1)]|"; NSDictionary *views; if (i < column.count - 1) { views = @{ @"view1": column[i], @"view2": column[i + 1] }; }else{ views = @{ @"view1": column[i - 1], @"view2": column[i] }; } NSArray * horizontalConstraints = [NSLayoutConstraint

How to make a UIImageView centered in a Scrollview when zoom out?

末鹿安然 提交于 2019-12-13 02:24:30
问题 Just trying to figure out a way to make a ordinary photo viewer for iPhone and I just couldn't make the zooming work. myimageview = UIImageView() myimageview.translatesAutoresizingMaskIntoConstraints = false myimageview.image = UIImage(named: "1") scrollview = UIScrollView() scrollview.delegate = self scrollview.backgroundColor = UIColor.brownColor() scrollview.minimumZoomScale = self.view.frame.width/myimageview.image!.size.width scrollview.maximumZoomScale = 1.0 scrollview

Margin between images in UIScrollView

早过忘川 提交于 2019-12-12 21:54:14
问题 The effect I'm after: Having spacing between images that is only visible while scrolling (like the photos app). A lot of old obj-c answers suggest extending the scroll view's bounds offscreen to make it page farther, and making this offscreen space the gap between images. The documentation for pagingEnabled states: If the value of this property is YES, the scroll view stops on multiples of the scroll view’s bounds when the user scrolls. So in trying to change the multiples value, I extended