autolayout

Auto Layout iOS 11 Toolbar UIBarButtonItem with customView

夙愿已清 提交于 2020-01-23 03:11:07
问题 Recently in our project there was a problem with a UIBarButtonItem that was using a customView. Before iOS 11 we did the layout via flexible spacing items. This didn't work anymore and so nothing was displayed. Because I didn't find an answer here on SO that really solved the issue for me, I looked into it and came up with a (admittedly kind of hacky) solution I wanted to share with you. Maybe it can help you or you have some feedback. This is mixed objc and swift code, hope you don't mind.

UIScrollView with scaled UIImageView using autolayout

别来无恙 提交于 2020-01-22 17:48:06
问题 Consider a UIScrollView with a single subview. The subview is an UIImageView with the following size constraints: Its height must be equal to the height of the UIScrollView . Its width must be the width of the image scaled proportionally to the height of the UIImageView . It is expected that the width of the UIImageView will be bigger than the width of the UIScrollView, hence the need for scrolling. The image might be set during viewDidLoad (if cached) or asynchronously. How do you implement

-[NSTextField intrinsicContentSize] always has undefined width

萝らか妹 提交于 2020-01-21 11:26:27
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I

-[NSTextField intrinsicContentSize] always has undefined width

和自甴很熟 提交于 2020-01-21 11:25:29
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I

-[NSTextField intrinsicContentSize] always has undefined width

给你一囗甜甜゛ 提交于 2020-01-21 11:25:28
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I

iOS7 hide status bar but not adjust top layout guide

和自甴很熟 提交于 2020-01-21 06:29:30
问题 I deal with autolayout set up in Interface Builder. I want to not offset views that are pinned to top layout guide when I hide status bar in runtime. I have discovered that myViewController.topLayoutGuide.length changes from 20 to 0 when hiding status bar. How to prevent it? Or (as workaround) how to set up fullscreen view for various window sizes without pin to top layout guide? Some code to describe my situation: Log(@"frame: %@, top: %.0f", NSStringFromCGRect(myViewController.myView.frame)

iOS7 hide status bar but not adjust top layout guide

我与影子孤独终老i 提交于 2020-01-21 06:29:25
问题 I deal with autolayout set up in Interface Builder. I want to not offset views that are pinned to top layout guide when I hide status bar in runtime. I have discovered that myViewController.topLayoutGuide.length changes from 20 to 0 when hiding status bar. How to prevent it? Or (as workaround) how to set up fullscreen view for various window sizes without pin to top layout guide? Some code to describe my situation: Log(@"frame: %@, top: %.0f", NSStringFromCGRect(myViewController.myView.frame)

Swift: Button round corner breaks contraints

此生再无相见时 提交于 2020-01-20 09:19:10
问题 I have a tableview with custom cell loaded via xib and in that cell I have status button which bottom right corner should be rounded. The button has constraints Trailing/Leading/Bottom space to superview=0 and height=30. Without rounding it is working perfectly, as soon as I round one corner for example bottom right the constraints breaks self.btnStatus.roundCorners(corners: [.bottomRight], radius: 7.0, borderWidth: nil, borderColor: nil) Some guys here suggesting to call layoutSubviews() but

Swift: Button round corner breaks contraints

孤街醉人 提交于 2020-01-20 09:18:26
问题 I have a tableview with custom cell loaded via xib and in that cell I have status button which bottom right corner should be rounded. The button has constraints Trailing/Leading/Bottom space to superview=0 and height=30. Without rounding it is working perfectly, as soon as I round one corner for example bottom right the constraints breaks self.btnStatus.roundCorners(corners: [.bottomRight], radius: 7.0, borderWidth: nil, borderColor: nil) Some guys here suggesting to call layoutSubviews() but

how to set scrollview content size with auto layout?

回眸只為那壹抹淺笑 提交于 2020-01-20 07:43:55
问题 I have one screen where I have added 1 scroll view on self view. Tab bar and navigation bar both are there and for iPhone 4 view height is 455.I have added more content on scroll view.the height of scroll view and self view is same.but when i am unable to set content size for scroll view.even i set too it is not working.Please help me. Thanks 回答1: Here is how to set up the size of the contentView in Auto Layout: Add a view to your scrollView. This should be the only top level view on your