UIImageView .scaleAspectFit and autolayout not working programmatically from Swift

后端 未结 1 1899
广开言路
广开言路 2021-01-22 06:42

I have several partly transparent PNG overlays to display overlaying one another in a view. The number of overlays varies depending on runtime conditions. I want to create the <

相关标签:
1条回答
  • 2021-01-22 07:08

    In your console log, these two lines tell you what's happening:

    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)

    .

    NSAutoresizingMaskLayoutConstraint:0x17009cc50 h=--& v=--& UIImageView:0x101432d20.midY == 877.5 (active)

    Adding this line to your code will fix things:

    swiftImageView.translatesAutoresizingMaskIntoConstraints = false
    
    0 讨论(0)
提交回复
热议问题