当视图第一次出现时,UILabel 文本大小未更新 iPad

UILabel text size is not getting updated for iPad when the view appears first time

我的屏幕上有一个标签,它给出了品牌行为。使用尺寸 类 我将标签尺寸设为 iPad 的特定尺寸。当视图出现在屏幕上时,标签大小为 smaller.But,当我导航到下一个视图并返回到该视图时,标签大小按预期更改。我希望在第一次出现视图时更改大小。有什么问题?

我在viewWillAppear中写了下面的代码

lblScrollingNotification.frame.origin.x = ScreenSize.SCREEN_WIDTH
    lblScrollingNotification.text = "This is a sample text to check the animation of the text in home screen"
    lblScrollingNotification.sizeToFit()
    UIView.animate(withDuration: 12.0, delay: 1, options: ([.curveLinear, .repeat]), animations: {() -> Void in

        self.lblScrollingNotification.center = CGPoint(x: self.lblScrollingNotification.bounds.size.width / 2, y : self.lblScrollingNotification.center.y)

    }, completion:  { _ in })

我把上面的代码写在了viewDidLayoutSubviews中,而不是viewWillAppear中。那解决了问题。