Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // JbD_Opus001_MainViewController.m
- // Pixel Coder
- //
- // Created by John E Russo on 1/9/13.
- // Copyright (c) 2013-2014 John E Russo. All rights reserved.
- //
- #import "JbD_Opus001_MainViewController.h"
- #import "JbD_Opus001_Converter.h"
- #import "Constants.h"
- @implementation JbD_Opus001_MainViewController
- {
- JbD_Opus001_Converter *myConverter;
- }
- @synthesize noBaseValueAlert, noConversionValueAlert, displayString, mainTextField, insetLabel, baseValueLabel, baseButton, firstConversionView, secondConversionView, thirdConversionView, pxUOMLabel, ptUOMLabel, percentUOMLabel, emsUOMLabel, pxValueLabel, ptValueLabel, percentValueLabel, emsValueLabel;
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- //init alert views
- noBaseValueAlert = [[UIAlertView alloc] initWithTitle:@"No Base Value" message:@"Enter a non-zero value and tap the Set Base button" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
- noConversionValueAlert = [[UIAlertView alloc] initWithTitle:@"No Conversion Value" message:@"Enter a value and tap a conversion button" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
- //init displayString
- displayString = [NSMutableString stringWithCapacity:4];
- //init Converter
- myConverter = [[JbD_Opus001_Converter alloc] init];
- //set nav controller's view b/g color
- self.view.backgroundColor = kMyGray;
- //grab nav bar from nav controller
- UINavigationBar *mainNavBar = [self.navigationController navigationBar];
- //change nav bar b/g to black
- mainNavBar.barStyle = UIBarStyleBlack;
- //customize title text
- NSDictionary *titleTextProperties = [[NSDictionary alloc] initWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica" size:18.0f], NSFontAttributeName, [UIColor whiteColor], NSForegroundColorAttributeName, nil];
- mainNavBar.titleTextAttributes = titleTextProperties;
- self.title = @"Pixel Coder";
- //build and add first conversion view
- CGRect firstConversionViewRect = CGRectMake(0.0f, 188.0f, 320.f, 73.0f);
- firstConversionView = [[UIView alloc] initWithFrame:firstConversionViewRect];
- firstConversionView.translatesAutoresizingMaskIntoConstraints = NO;
- firstConversionView.backgroundColor = [UIColor blackColor];
- [self.view addSubview:firstConversionView];
- //build and add second conversion view
- CGRect secondConversionViewRect = CGRectMake(0.0f, 262.0f, 320.f, 76.0f);
- secondConversionView = [[UIView alloc] initWithFrame:secondConversionViewRect];
- secondConversionView.translatesAutoresizingMaskIntoConstraints = NO;
- secondConversionView.backgroundColor = [UIColor blackColor];
- [self.view addSubview:secondConversionView];
- //build and add third conversion view
- CGRect thirdConversionViewRect = CGRectMake(0.0f, 339.0f, 320.f, 77.0f);
- thirdConversionView = [[UIView alloc] initWithFrame:thirdConversionViewRect];
- thirdConversionView.translatesAutoresizingMaskIntoConstraints = NO;
- thirdConversionView.backgroundColor = [UIColor blackColor];
- [self.view addSubview:thirdConversionView];
- //constraints for conversion views
- [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=188)-[firstConversionView(73)]-1-[secondConversionView(76)]-1-[thirdConversionView(77)]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(firstConversionView, secondConversionView, thirdConversionView)]];
- [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[firstConversionView(320)]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(firstConversionView, secondConversionView, thirdConversionView)]];
- [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[secondConversionView(320)]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(firstConversionView, secondConversionView, thirdConversionView)]];
- [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[thirdConversionView(320)]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(firstConversionView, secondConversionView, thirdConversionView)]];
- //build and add percent UOM label
- CGRect percentUOMLabelRect = CGRectMake(260.0f, 20.0f, 30.0f, 30.0f);
- NSParagraphStyle *percentUOMLabelStyle = [NSParagraphStyle defaultParagraphStyle];
- NSDictionary *percentUOMLabelTextDictionary = [[NSDictionary alloc]initWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica" size:24.0f], NSFontAttributeName,[UIColor whiteColor], NSForegroundColorAttributeName, percentUOMLabelStyle, NSParagraphStyleAttributeName, nil];
- NSAttributedString *percentUOMLabelText = [[NSAttributedString alloc] initWithString: @"%" attributes:percentUOMLabelTextDictionary];
- percentUOMLabel = [[UILabel alloc] initWithFrame:percentUOMLabelRect];
- percentUOMLabel.attributedText = percentUOMLabelText;
- percentUOMLabel.backgroundColor = [UIColor clearColor];
- //build and add ems UOM Label
- CGRect emsUOMLabelRect = CGRectMake(260.0f, 20.0f, 35.0f, 30.0f);
- NSParagraphStyle *emsUOMLabelStyle = [NSParagraphStyle defaultParagraphStyle];
- NSDictionary *emsUOMLabelTextDictionary = [[NSDictionary alloc]initWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica" size:24.0f], NSFontAttributeName,[UIColor whiteColor], NSForegroundColorAttributeName, emsUOMLabelStyle, NSParagraphStyleAttributeName, nil];
- NSAttributedString *emsUOMLabelText = [[NSAttributedString alloc] initWithString: @"em" attributes:emsUOMLabelTextDictionary];
- emsUOMLabel = [[UILabel alloc] initWithFrame:emsUOMLabelRect];
- emsUOMLabel.attributedText = emsUOMLabelText;
- emsUOMLabel.backgroundColor = [UIColor clearColor];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement