Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
55 views

I need to show occasional long texts in a UIButton in the section header of my UITableView. The following simple example code shows the issue: import UIKit import SnapKit class ViewController: ...
2 votes
1 answer
9k views

Within UIView I have a method presentView(): public func presentView() { UIApplication.sharedApplication().delegate?.window??.addSubview(self) let blurEffect = UIBlurEffect(style: ....
183 votes
19 answers
107k views

I created two views in one superview, and then added constraints between views: _indicatorConstrainWidth = [NSLayoutConstraint constraintWithItem:self.view1 attribute:NSLayoutAttributeWidth relatedBy:...
8 votes
1 answer
5k views

I keep references to my NSLayoutConstraint var flag = true @IBOutlet weak var myConstraint: NSLayoutConstraint! Then for some @IBAction I activate/deactivate depending on my flag variable: @IBAction ...
2 votes
1 answer
114 views

Example project: http://cl.ly/1g1L3E2Z0r1c I create a nib file and then create some views in it, which I then load into another view controller. In the view that I bring in, it's a subclass of UIView ...
0 votes
4 answers
702 views

I would like to place 4 buttons on the screen. They should be all of the same height and width. The margin between the buttons should be 35px and the outter margin to the views border should be 20px. ...
0 votes
0 answers
56 views

I have a simple NSTextView inside a scroll view, as follows: self.suggestionTextView = NSTextView() self.suggestionTextView.isEditable = true self....
573 votes
19 answers
706k views

I'm trying to figure this out since last week without going any step further. Ok, so I need to apply some constraints programmatically in Swift to a UIView using this code: var new_view:UIView! = ...
1 vote
1 answer
113 views

I am using SnapKit for auto layout in my iOS app. I need to show an image view at the very top of the screen. It will have an image of dynamic height and width. I need its top edge to be aligned with ...
1 vote
0 answers
145 views

Targets: Tested with iPhone 16 Pro with iOS 18.0 (Simulator) iPhone 6s with iOS 15.8.1 (Physical device) I have an UIKit UIViewController component (instance of UIPageViewController, repo: here). I'...
68 votes
13 answers
14k views

I have a storyboard with Autolayout and Size Classes. Pretty complicated layout, and unfortunately I can't really pin down how to reproduce the problem in a new project. But the view in question is ...
77 votes
3 answers
57k views

I've read the documentation. But I'm still not sure when I need to set it to true. In the code below if I set it to false I won't see the header at all. If I leave it as true, then everything is fine. ...
6 votes
1 answer
2k views

I have a ScrollViewReader and the scrollTo method works. proxy.scrollTo(target, anchor: .top) The item which is scrolled to is completely aligned with the .top-Anchor. Now I want to include the ...
21 votes
3 answers
61k views

I'm trying to make a view that will act as a sort of "panel", attached to the right side of the view controller. That is, it is bound to the trailing, top, and bottom margins of the parent view ...
0 votes
2 answers
605 views

I am making a sign up screen and would like to update a few top anchors so that when the keyboard appears, the top anchor constant decreases and the keyboard doesn't cover any text fields. I have ...
1 vote
0 answers
68 views

How can I calculate the optimal size of a NSView based on its current constraints and a target size? UIView provides: func systemLayoutSizeFitting(_ targetSize: CGSize) -> CGSize func ...
-1 votes
1 answer
126 views

Trying to get a spring animation to work properly. I made a git repo. Basically the red view is constrained as follows: let ac = brokenView.widthAnchor.constraint(equalTo: brokenView.heightAnchor, ...
0 votes
1 answer
631 views

I am developing a Log-In screen using XCode 15.2 and the latest version of SwiftUI that is shipped in Xcode. The Simulator I use is the iPhone 15 Pro. The Log-In Screen has two TextFields one contains ...
-2 votes
2 answers
117 views

Say you have some large complex custom view, lazy var pinkThing: .. lazy var greenThing: .. And you want to ///For upstream views to use as they wish var pinkCenterY: NSLayoutYAxisAnchor { return ...
0 votes
1 answer
83 views

Here is how i have configured the profile view, -(void)addProfileView { if(!_profileView) { _profileView = [ProfileView new]; _profileView.clipsToBounds = YES; ...
0 votes
1 answer
50 views

I am trying to draw onto a subview (subclass of UIView) that I have added to a UICollectionViewCell's contentView. I did this by implementing a drawRect function to draw a very simple cross in the ...
4 votes
2 answers
5k views

I'm really very weak in constraints part of ios. I have gone through many reference link as shown below but still not able solve my issue. Hide autolayout UIView : How to get existing ...
3 votes
3 answers
493 views

I would like to programmatically move all subviews of a UIView to another UIView while keeping all constraints between the subviews to each other and to the (new) parent intact. What is the "...
95 votes
4 answers
51k views

I can't find a way to create a 'square' constraint, meaning 'width equals height' in Interface Builder. I guess it's possible to add such constraint programmatically. Is there something I can do in IB?...
0 votes
1 answer
355 views

I've created a UIView, which has buttons in it. I set the constraints like this : NSLayoutConstraint.activate([ sampleView.topAnchor.constraint(equalTo: topView.bottomAnchor, constant: 20), ...
1 vote
4 answers
219 views

I have this images views: I want that for every device that the distance between the first imageview and the left side it's the same , then the distance between the first imageview and the second ...
128 votes
18 answers
173k views

I would like the UICollectionView (The red one) to shrink to the height of the content size in this case UICollectionViewCells(the yellow ones) because there is a lot of empty space. What I tried is ...
1 vote
1 answer
63 views

I'm using an SF symbol image into a UIImageView. I have given the constrains as well. What I have seen running the same code into different simulators actually increases the width of the image but I ...
132 votes
6 answers
26k views

The question I have is simple but I couldn't find any information in the documentation. What happens with layout constraints when a view is removed from the view hierarchy (or moved to another view)? ...
0 votes
1 answer
74 views

I have taken image and I want flyView to be drop from top middle to 200 from top and vanishes. for that tried like this code: here I have given constraints for flyView as flyView.centerXAnchor and ...
3 votes
1 answer
1k views

I would like to add programmatically few constraints while I slide from a bottom new table view, but so far I can not understand what am I doing wrong. In my super view I have map view which have to ...
5 votes
1 answer
949 views

When I run my app on an iPhone I get the following errors. When I run it in the simulator I do not. If I take the -12-| away then the cell's height collapses to something like 30 pixels and the UI ...
0 votes
1 answer
406 views

I am a mildly experienced UIKit/AppKit developer, but I am just getting started using SwiftUI. In UIKit it is straight forward to constrain two UIView's to have the same size and position using ...
0 votes
1 answer
46 views

I am setting a tableView but when running the app, the label's content is not stable, sometimes it shows full content, sometimes it doesn't. Looking for advise. I attached the images for .xib setup ...
108 votes
7 answers
132k views

I have used auto layout for my view controllers. I have set the V and H positions in constraints, but I want to know how can I increase my button size when it changes to 5s, 6 and 6 Plus. This is the ...
0 votes
2 answers
1k views

I have a simple UICollectionView in a view controller. I am animating the top constraint of the collection view via a button. On the FIRST button tap, the collection view cells are animating quite ...
22 votes
8 answers
24k views

I am trying to find the top constraint of the view in code. The top constraint is added in storyboard, and I don't want to use an IBOutlet. Logging the value of the firstAttribute in the following ...
0 votes
1 answer
148 views

Problem: I am having some issues using the correct frame values to simulate viewport percentages when sizing subviews of a modal view-controller. I would rather size subviews using layout constraints ...
2 votes
1 answer
745 views

I have a method that creates a mask layer based on the current frame of my UIImageView, which works as I expected. However, in one case, I modify the height constraint of a UIImageView in the ...
0 votes
1 answer
541 views

I am attempting to create a Swift-based UI programmatically that resembles the layout shown below Below is my view hierarchy which I created using xib. Now I'm attempting to achieve the same through ...
0 votes
0 answers
73 views

IMPORTANT: I know how to use Auto-Layout. How to use it has been asked before already and this is not a duplicate of that question. Auto-Layout is Apple’s cross-platform constraint-based layout system....
0 votes
1 answer
89 views

When you build an UI programatically with swift and constraints, you can notice that most views have some height or width, and you don't need to define it. For example UILabel, if you make constraints ...
24 votes
9 answers
22k views

I have a UIView subclass that contains a multi-line UILabel. This view uses autolayout. I would like to set this view as the tableHeaderView of a UITableView (not a section header). The height of this ...
4 votes
2 answers
2k views

I have a custom meter view. And a label that shows the numeric value graphed by the meter. Using AutoLayout constraints, I want to align the baseline of the label with the bottom of the view. When I ...
1 vote
0 answers
232 views

I made textview and imageview and label inside scrollview, and I add textView.isScrollEnabled = false to scroll both. My Question is, When I click enter in the textview at the last line, My textview ...
4 votes
1 answer
773 views

I have created UITableviewCell programmatically and trying to load in table view Cell has just one imageView and UIlabel. Although the UI looks fine , but I am seeing this warning : Unable to ...
-1 votes
1 answer
230 views

I'm trying to set up UI for ViewController through NSLayoutConstraint. Here's the code I'm using: class ProfileViewController: UIViewController { private var profileUser = katyPerry ...
2 votes
1 answer
948 views

I have a UIViewController which has a UIView that plays a video. The constraints given to this UIView are as follows. Trailing space to : Superview Leading space to :Superview Top space to ...
-1 votes
1 answer
74 views

I have the following implementation of a UIView.. struct LoginView { let loginView: UIView = UIView() func layoutLoginView() -> UIView { loginView....
-1 votes
3 answers
1k views

I am practicing auto-layout programmatically. I want to put a UIView centered in the controller whose width will be 4/5 in portrait mode but when it will go to the landscape mode, I need the height to ...

1
2 3 4 5
43