ios-autolayout

How to design a dynamic layout with two TableViews in Swift

让人想犯罪 __ 提交于 2019-12-14 03:30:03
问题 Hi fellow programmers. I've spent many hours trying to design this layout in Swift, with little success. Drawing of the layout The idea is having two TableViews: The top one, with zero or more (indefined) cells, which can't be scrollable and its height grows with the number of cells. The bottom one, with zero or more (indefined) cells, which is scrollable, and thus its height adapts to the space left from the latter tableview. I've already tried to play with the constraints programmatically,

Centering a UIView programmatically using Autolayout makes the view disappear from superview

Deadly 提交于 2019-12-13 16:11:44
问题 I have the following code to simply center a red square using AutoLayout constraints programmatically in my ViewController 's view : class ViewController: UIViewController { let square: UIView required init?(coder aDecoder: NSCoder) { let squareFrame = CGRectMake(0.0, 0.0, 500.0, 500.0) self.square = UIView(frame: squareFrame) super.init(coder: aDecoder) } override func viewDidLoad() { self.view.addSubview(self.square) self.square.backgroundColor = UIColor.redColor() self.view.backgroundColor

iOS Autolayout: constraints for three squares

爱⌒轻易说出口 提交于 2019-12-13 09:23:46
问题 I'm trying to achieve a very simple scenario using auto layout but without success. Please help me... I need 3 squares with a dynamic size(ex: on iPad, all of them should be scaled) on a table cell. I have spend already some hours finding a solution.... This picture showing how the view should look like: Thanks 回答1: You can do it with autoresizing tool which is appear in size inspector. Step1: Place your views in which ever pattern you want. Step2: Then select a view and click on size

Change height and width of view according to scrollview scroll horizontally using auto layout

孤人 提交于 2019-12-13 08:54:25
问题 Container View hierarchy:- Container View Scrollview view left view center view right FloatingBottomView I need to change height and width constrain of FloatingBottomView according to scrollview scroll horizontally. Initial Outlet:- @IBOutlet weak var constantFloatingBottomViewWidth: NSLayoutConstraint! // 300 @IBOutlet weak var constantFloatingBottomViewHeight: NSLayoutConstraint! // 70 override func viewWillAppear(_ animated: Bool) { self.scrollView.contentOffset.x = self.view.bounds.width

how to set auto layout for dynamically created buttons?

孤街浪徒 提交于 2019-12-13 04:55:42
问题 i am creating dynamic buttons and labels with scroll view now i want set auto layout for that . hows its possible set multiple dynamic buttons .i search many tutorial but not got any example for set auto layout multiple dynamic buttons.its work but all buttons are set together .means show only one button and label. but i am search its show correct result but auto layout is not work . what the problem -(void)DynamicButton:(NSMutableArray*)objectName { for(UIView *view in [scrollView subviews])

Changing Auto Layout Anchor Constrains

余生长醉 提交于 2019-12-13 03:42:04
问题 I have a UITextField , and I'm trying to change its position when the keyboard comes up. More specifically, I want to move the text field up so that it sits just above the keyboard. My code looks something like this let textField = myCustomTextField() override func viewDidLoad() { //set up textfield here //constrains blah blah textField.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -view.bounds.height * 0.05).isActive = true //more constraints } What I want

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 scale a UIImage view to a square with Autolayout inside a UIScrollView

泪湿孤枕 提交于 2019-12-13 02:18:11
问题 I've been struggling to learn autolayout (finally). I want to have a vertically scrolling UIScrollView that holds all the content for the view. I want to pin a UIImage view to the top of the scrollview and keep the image a square (scaleToFill). Basically I want to do this (only I want to do it with autolayout): I can't get the image to keep its aspect ratio while staying within the screen bounds. Whenever I add an aspect ratio constraint the imageView grows to like 600 points (the width of

changing the font size according to each iPhone size

半腔热情 提交于 2019-12-12 07:57:11
问题 is there any way to changing/auto resizing the font size according to the different iPhone screen as when i change the font size, the font size applied to other phone size as well which is too big. My Current Phone size is iPhone 6s plus (5.5 inch) 回答1: Please use size classes to support different font size for different screens. Here is good tutorial about using size classes. adaptive-layout-tutorial 回答2: I ran in to a similar issue. I suggest to use this library: https://github.com/hamiz

AutoLayout constraint issues in iOS 10, XCode 8

▼魔方 西西 提交于 2019-12-12 03:52:58
问题 As I have developed the iOS application using Xcode 7.3 . When reviewing the AutoLayout constraint on the device which having iOS 10 using Xcode 7.3 it properly display it but when using the Xcode 8 and then reviewing on the device then it does not show properly. So my question if I am deploy the application on the AppStore using Xcode 7.3 , so there is any chance that the AutoLayout constraint do not show properly in iOS 10 . Any help is much appreciated. 回答1: I am having the same issues in