How to center a UILabel on UIView

前端 未结 7 2011
日久生厌
日久生厌 2020-12-13 06:12

How can I center the UILabel on the UIView? I am using the following code

float width = weatherView.bounds.size.width; 
float height = weatherView.bounds.siz         


        
7条回答
  •  一个人的身影
    2020-12-13 06:55

    There are two possibility if your UILabel is added via .xib or else added programmatically .

    If first case i.e added via .xib then you can set the position from xib file size inspector tab with the 'Arrange' property

    And if second case persist then you can set as --- [self.label setCenter:view.center];

提交回复
热议问题