How to center a UILabel on UIView

john doe picture john doe · Jul 19, 2011 · Viewed 81.3k times · Source

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.size.height; 

[self.label setFrame:CGRectMake(width-100,height-100, 100, 100)];

Answer

PengOne picture PengOne · Jul 19, 2011

How about:

[self.label setCenter:view.center];