Questions tagged [autolayout]

Auto Layout is a constraint-based, descriptive user interface layout system for OS X and iOS.

The Auto Layout system defines layout constraints for user interface elements. Constraints represent relationships between user interface elements such as “these views line up head to tail,” or “this button should move with this split view subview.” When laying out the user interface, a constraint satisfaction system arranges the elements in a way that most closely meets the constraints. Constraints are objects and can be established in storyboards and XIBs, exposed as outlets, and created or modified in code.

11052 questions
4
votes
2 answers

IOS Auto Lay out dynamic leading and trailing constraints

How can we set dynamic leading and trailing constraints like we give dynamic width and height through percentage of screen size.
Muhammad Umar
  • 131
  • 2
  • 8
4
votes
1 answer

iOS | How to get runtime image width/height in swift

I am using 'Aspect Fit' mode imageview in a full screen in Swift storyboard. Actual image is fitting well keeping the ratio. Problem is i cannot get the actual image width/height on runtime. When I use imageview.frame.size.width, it's returning the…
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
4
votes
1 answer

What can prevent Auto Layout constraints from being respected during animations?

I'm trying to snap a view to a UITabBarController's tabBar (UITabBar) to never hide it (the way Apple does it in the 'Featured' tab of the tvOS App Store). I can make it work by setting up my constraints in a UIViewController that's directly…
Felix Lapalme
  • 1,058
  • 1
  • 11
  • 25
4
votes
1 answer

UILabel Subclass - Custom 'drawRect' method causes text to cut off / not show

I am creating a simple 'tooltip' subclass that is a rounded rectangle and a small triangle that will be 'anchored' to another view. I created a UILabel subclass and am overriding 'drawRect' to shrink the main label area and draw a triangle. The…
JimmyJammed
  • 9,598
  • 19
  • 79
  • 146
4
votes
1 answer

Center alignments greyed out in Xcode 7.2

Why are the the vertical and horizontal center alignments greyed out?
Peter
  • 1,848
  • 4
  • 26
  • 44
4
votes
1 answer

How to convert my iOS App from iPhone to universal in Xcode 7 or later?

I have searching questions for my query and I got similar questions, but with older versions of Xcode. Is there any new things available in latest version of Xcode that can make it easy to make iPhone developed project to Universal ? Second thing, I…
NSPratik
  • 4,714
  • 7
  • 51
  • 81
4
votes
3 answers

How to set full width image inside UIScrollView in swift

I need to display large content in my UIViewController added in Storyboard so I added UIScrollView with constraints top, right, bottom, left:0 ( to make it full screen ). In top of UIScrollView I need a square image with its width as device screen…
Dashrath
  • 2,141
  • 1
  • 28
  • 33
4
votes
2 answers

Autolayout issue with zoomed display with iPhone6 and 6Plus

I am using Auto Layout and Size Classes in my storyboard and have a button that has a vertical constraint to the bottom of my view controller. However, when I run my app on my iPhone6 Plus in zoomed mode (Settings -> Display & Brightness -> Display…
m.y
  • 691
  • 9
  • 21
4
votes
0 answers

AVPlayerViewController fullscreen issues constraint warnings

I am trying to create an UIViewController with some labels and a movie in the middle of the screen. For the movie, I am using AVPlayerViewController but, whenever I click on its fullscreen button, I receive several constraint warnings even if I…
4
votes
1 answer

Using NSLayoutConstraint on a subview in conjuction with an affine transform

I need to have vertical sliders. To do this, I have a UIView class that contains a UISlider, and inside initWithFrame:, I rotate the slider with an affine transform by 90 degrees. I'm now adding Autolayout support to it. I wish to allow the slider…
Justin
  • 119
  • 9
4
votes
0 answers

iOS How to cancel a UIView animation

I reset a constraint and do animation (self.view.layoutIfNeeded()) delay 3 seconds ,In some cases I want to remove the animation , what shall I do, I have tried self.view.layer.removeAllAnimations() but not working this is my animation…
jansma
  • 1,605
  • 1
  • 15
  • 22
4
votes
1 answer

Adding subview to custom view ends up wrong due to auto layout haven't calculated dimensions

I have created a custom view class. I have a image view that I want to blur. I have added the blurring effect in the code below, but obviously it doesn't work because the bounds of the image view is wrong. Due to auto layout haven't calculated the…
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
4
votes
2 answers

Regular / Regular spacing between views for all iPads and iPad Pro?

I've recently been encountering a difference in the regular / regular sizing class among different iPads, here's my related question Regular / Regular position sizing constraints for all iPads, including iPad pro? Although I can use a multiplier and…
Jules
  • 7,568
  • 14
  • 102
  • 186
4
votes
2 answers

UIScrollView with Autolayout Ambigous height

I've read a lot of manuals/tutorials on ScrollViews with vertical scrolling, but havent figured out how to solve my problem so far. You can see my ScrollView visual plan here: ScrollView plan The most helpful answer was here, on…
oleskii
  • 366
  • 3
  • 14
4
votes
3 answers

How can I set the top Constraint to be 20 percent of the screen height?

I have an UIImageView in the in the controller's view with a distance of 20% of the screen height from the top of the view. ie I want to set the 20 % of the screen height as the top Constraint of the UIImageView. Can I implement this without adding…
jkdev
  • 93
  • 1
  • 9