Constraints not updating with device orientation change

前端 未结 1 502
名媛妹妹
名媛妹妹 2021-01-25 12:26

I have a color slider in a tableView cell that extends from the label to the trailingAnchor of the cell. The issue I am having is when the device orientation changes the color s

相关标签:
1条回答
  • 2021-01-25 12:48

    CALayers will not be resized in response to their parent UIView being resized, whether by auto layout or manually.

    You just need to add code to your ColorSlider that updates the layer when the size/position of the ColorSilider changes. Luckily, there is a method on UIView that is specifically for this.

    override func layoutSubviews() {
        super.layoutSubviews()
        gradientLayer.frame = bounds
    }
    
    0 讨论(0)
提交回复
热议问题