-
-
Save edopelawi/fdad98a34aa4c37c75ff to your computer and use it in GitHub Desktop.
MessyViewDidLoad without unnecessary comments and renamed variables
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]; | |
CGFloat yPositionOffset = 64.0f; | |
CGFloat defaultViewWidth = self.view.frame.size.width; | |
//Top most view | |
CGFloat topMostViewHeight = 100.0f; | |
UIView *topMostView = [[UIView alloc] initWithFrame:CGRectMake(0, yPositionOffset, defaultViewWidth, topMostViewHeight)]; | |
topMostView.backgroundColor = [UIColor redColor]; | |
//Title | |
CGFloat titleHeight = 50.0f; | |
CGFloat titleWidth = 100.f; | |
CGFloat titleXPosition = (defaultViewWidth - titleWidth) / 2; | |
CGFloat titleYPosition = (topMostViewHeight - titleHeight) / 2; | |
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(titleXPosition, titleYPosition, titleWidth, titleHeight)]; | |
title.text = @"Colors Page"; | |
title.textColor = [UIColor whiteColor]; | |
[topMostView addSubview:title]; | |
[self.view addSubview:topMostView]; | |
yPositionOffset += topMostViewHeight; | |
// Bottom view | |
CGFloat bottomViewHeight = 150.0f; | |
UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, yPositionOffset, defaultViewWidth, bottomViewHeight)]; | |
bottomView.backgroundColor = [UIColor blueColor]; | |
//Copyright | |
CGFloat copyrightHeight = 55.0f; | |
CGFloat copyrightWidth = 150.0f; | |
CGFloat copyrightXPosition = (defaultViewWidth - copyrightWidth) / 2; | |
CGFloat copyrightYPosition = (bottomViewHeight - copyrightHeight) / 2; | |
UILabel *copyright = [[UILabel alloc] initWithFrame:CGRectMake(copyrightXPosition, copyrightYPosition, copyrightWidth, copyrightHeight)]; | |
copyright.text = @"All rights reserved"; | |
copyright.textColor = [UIColor whiteColor]; | |
[bottomView addSubview:copyright]; | |
[self.view addSubview:bottomView]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment