Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MainView.m
- // day2
- //
- // Created by Axel Soedarsono on 8/30/17.
- // Copyright © 2017 Axel Soedarsono. All rights reserved.
- //
- #import "MainView.h"
- @interface MainView ()
- @property (strong, nonatomic) UIView *informationImageView;
- @property (strong, nonatomic) UIView *informationDataView;
- @property (strong, nonatomic) UIImageView *firstImageView;
- @property (strong, nonatomic) UILabel *title1Label;
- @property (strong, nonatomic) UILabel *cityLabel;
- @property (strong, nonatomic) UILabel *temperatureLabel;
- @property (strong, nonatomic) UILabel *weatherLabel;
- @property (strong, nonatomic) UITextField *inputTextField;
- @property (strong, nonatomic) UIButton *usecurrentLocationButton;
- @end
- @implementation MainView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if(self){
- //set backgroundcolor
- self.backgroundColor = [UIColor lightGrayColor];
- //view 1 -> imageView
- _informationImageView = [[UIView alloc] initWithFrame:CGRectMake(16.0f , 88.0f, CGRectGetWidth([UIScreen mainScreen].bounds) - 16.0f - 16.0f, 100.0f)];
- self.informationImageView.backgroundColor = [UIColor darkGrayColor];
- self.informationImageView.layer.cornerRadius = CGRectGetHeight(self.informationImageView.frame)/2.0f;
- [self addSubview:self.informationImageView];
- //image
- _firstImageView = [[UIImageView alloc] initWithFrame:CGRectMake((CGRectGetWidth(self.informationImageView.frame) - CGRectGetHeight(self.informationImageView.frame))/2.0f, 0.0f, CGRectGetHeight(self.informationImageView.frame), CGRectGetHeight(self.informationImageView.frame))];
- self.firstImageView.image = [UIImage imageNamed: @"image"];
- self.firstImageView.contentMode = UIViewContentModeScaleAspectFill;
- self.firstImageView.layer.borderWidth = 5.0f;
- self.firstImageView.layer.borderColor = [UIColor whiteColor].CGColor;
- self.firstImageView.layer.cornerRadius = CGRectGetHeight(self.firstImageView.frame)/2.0f;
- self.firstImageView.clipsToBounds = YES;
- self.firstImageView.backgroundColor = [UIColor whiteColor];
- [self.informationImageView addSubview:self.firstImageView];
- //title1Label
- _title1Label = [[UILabel alloc] initWithFrame:CGRectMake((CGRectGetWidth([UIScreen mainScreen].bounds))/ 4.0f, CGRectGetMaxY(self.informationImageView.frame) + 16.0f, CGRectGetWidth([UIScreen mainScreen].bounds)/ 2.0f, 24.0f)];
- self.title1Label.text = @"WEATHER APP";
- self.title1Label.textColor = [UIColor whiteColor];
- self.title1Label.adjustsFontSizeToFitWidth = YES;
- self.title1Label.textAlignment = NSTextAlignmentCenter;
- self.title1Label.backgroundColor = [UIColor blackColor];
- [self addSubview:self.title1Label];
- //inputTextField
- _inputTextField = [[UITextField alloc] initWithFrame:CGRectMake(24.0f, CGRectGetMaxY(self.title1Label.frame) + 16.0f, CGRectGetWidth([UIScreen mainScreen].bounds) - 24.0f - 24.0f, 24.0f)];
- self.inputTextField.textColor = [UIColor blackColor];
- self.inputTextField.backgroundColor = [UIColor whiteColor];
- self.inputTextField.adjustsFontSizeToFitWidth = YES;
- self.inputTextField.textAlignment = NSTextAlignmentCenter;
- [self addSubview:self.inputTextField];
- //useCurrentLocationBUtton
- _usecurrentLocationButton = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.inputTextField.frame), CGRectGetMaxY(self.inputTextField.frame) + 16.0f, CGRectGetWidth([UIScreen mainScreen].bounds) - CGRectGetMinX(self.inputTextField.frame) - CGRectGetMaxX(self.inputTextField.frame) , 24.0f)];
- [self.usecurrentLocationButton setTitle:@"use current location" forState:UIControlStateNormal];
- [self.usecurrentLocationButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- self.usecurrentLocationButton.backgroundColor = [UIColor brownColor];
- [self addSubview:self.usecurrentLocationButton];
- }
- return self;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement