intrinsic-content-size

How to have a DIV with fixed aspect ratio and max-height? (Pure CSS/no vh or vw)

被刻印的时光 ゝ 提交于 2020-02-03 02:31:07
问题 My initial problem like many others is to keep a DIV A with a fixed aspect ratio (pure CSS/no JS). It is intended to be reused in any parent DIV B regardless the sizing of B. DIV A should fit the smallest size of B. In this animation, you can see the RED div that is always a square and that fits the outermost div smallest size. No vh or vw or vmin or vmax is used and I don't want to use any of them because vh is sometimes no more reliable to really represent the viewport height (see CSS3

How to make a custom view's frame match its instrinsic content size

本小妞迷上赌 提交于 2019-12-24 01:47:05
问题 Custom Label that Resizes According to its Contents I'm making a label from scratch. (My end purpose is to make a vertical text label for Mongolian script, but for now I am just making a normal horizontal text label as practice.) As long as there are no length and width constraints, I want my custom label's frame to resize according to its intrinsic content size. It Works in IB In IB everything seems to be working fine when I test a UILabel , my custom label (a UIView subclass), and a button.

Why isn't UIButton returning correct constraints?

两盒软妹~` 提交于 2019-12-19 05:44:28
问题 In my code below: I have 5 buttons added into a vertical scrollView. Each button is constrained to the scrollViews's top + 20 ,leading, trailing edges and its height. I have created a b1HeightConstraint variable. It's there to hold the heightConstraint of the b1 button. In a button click, I'm trying to remove this constraint. Yet I'm facing an odd issue: When I log the constraints I only see 2 constraints, even though I've added 4 constraints to it. My the view debug hierarchy is like below:

How to set a custom view's intrinsic content size in Swift?

戏子无情 提交于 2019-12-17 21:45:14
问题 Background I am making a vertical label to use with traditional Mongolian script. Before I was just rotating a UILabel but there were some performance issues and other complications with this. Now I am working on making a label from scratch. However, I need the vertical label to tell auto layout when its height adjusts (based on string length). What I have read I read the Intrinsic Content Size and Views with Intrinsic Content Size documentation. These were more about how to use it, though,

How does addSubview work with intrinsicSizes?

假装没事ソ 提交于 2019-12-08 11:00:25
问题 The result of the following code is: I don't see the label. My understanding was that the intrinsicSize of the label would allow the label to stretch . Why isn't that happening? import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.addSubview(label) } let label : UILabel = { let label = UILabel() label.text = "How are you doing today my friend" label.backgroundColor = .orange return label }() } 回答1: This: let label = UILabel() creates a

How To: Self-Sizing Custom-View from XIB with StackView View in iOS

巧了我就是萌 提交于 2019-12-04 08:56:25
问题 I've recently started diving into iOS development with Swift again and am now looking into a custom UIControl. For layout and flexibility this custom view is built using a StackView. What I want to achieve ... ... is basically to simply have the same functionality with the StackView that I usually have when I drag it directly into the storyboard - where it resizes to fit no problem. This essentially the same as self-sizing tableview cells. Showcase I can reduce my CustomView to a simple

How To: Self-Sizing Custom-View from XIB with StackView View in iOS

左心房为你撑大大i 提交于 2019-12-03 01:24:10
I've recently started diving into iOS development with Swift again and am now looking into a custom UIControl. For layout and flexibility this custom view is built using a StackView. What I want to achieve ... ... is basically to simply have the same functionality with the StackView that I usually have when I drag it directly into the storyboard - where it resizes to fit no problem. This essentially the same as self-sizing tableview cells. Showcase I can reduce my CustomView to a simple example: It's a StackView with three labels in it, Alignment set to Center , Distribution Equal Centering .

How to set a custom view's intrinsic content size in Swift?

社会主义新天地 提交于 2019-11-28 16:05:38
Background I am making a vertical label to use with traditional Mongolian script. Before I was just rotating a UILabel but there were some performance issues and other complications with this. Now I am working on making a label from scratch. However, I need the vertical label to tell auto layout when its height adjusts (based on string length). What I have read I read the Intrinsic Content Size and Views with Intrinsic Content Size documentation. These were more about how to use it, though, and not how to define it in a custom view. Searching for "ios intrinsic content size for a custom view"