How to keep a round imageView round using auto layout?

后端 未结 15 1382
悲&欢浪女
悲&欢浪女 2020-12-01 06:22

How do I turn a rectangular image view into a circular image view that can hold shape in auto layout without setting width and height restraints? Thereby allowing the imageV

15条回答
  •  一生所求
    2020-12-01 06:36

    I have same problem, and Now I get what happened here, hope some ideas can help you: there are something different between the tows:

    1. your profileImageView in storyboard
    2. your profileImageView in viewDidLoad

    the size of bound and frame is different when viewDidLoad and in storyboard,just because view is resize for different device size. You can try it print(profileImageView.bounds.size) in viewDidLoad and viewDidAppear you will find the size in viewDidLoad you set cornerRadius is not the real "running" size.

    a tips for you: you can use a subClass of ImageView to avoid it, or do not use it in storyboard,

提交回复
热议问题