Skip to content

Instantly share code, notes, and snippets.

@edopelawi
Last active September 10, 2015 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edopelawi/fdad98a34aa4c37c75ff to your computer and use it in GitHub Desktop.
Save edopelawi/fdad98a34aa4c37c75ff to your computer and use it in GitHub Desktop.
MessyViewDidLoad without unnecessary comments and renamed variables
- (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