#This simple snippet shows how to add a subview to superview's center.
Created
January 17, 2018 01:24
-
-
Save Lancewer/5499737e56b87214babfe57779fab643 to your computer and use it in GitHub Desktop.
[AddSubviewToSuperViewCenter] how to add a subview to superview's center #UIView #center #iOS #OC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
UIView *innerView = [[UIView alloc] init]; | |
[innerView setBounds:CGRectMake(0, 0, 50, 50)]; | |
[innerView setCenter:self.view.center]; | |
[self.view addSubview:innerView]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment