Animating UILabel Font Size Change

前端 未结 9 2066
醉话见心
醉话见心 2020-11-30 21:31

I am currently making an application that uses a custom View Controller container. Multiple views are on the screen at one time and when one is tapped, the selected view con

9条回答
  •  执笔经年
    2020-11-30 21:35

    For 2017 onwards....

    Swift 3.0, 4.0

    UIView.animate(withDuration: 0.5) {
         label.transform = CGAffineTransform(scaleX: 1.1, y: 1.1) //Scale label area
     }
    

    Critical:

    The critical point to avoid blurring is you must begin with the biggest size, and shrink it. Then expand to "1" when needed.

    For quick "pops" (like a highlight animation) it's OK to expand beyond 1 but if you are transitioning between two sizes, make the larger size the "correct" normal one.

提交回复
热议问题