Advertisement
axelso

day 2

Aug 30th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. //
  2. // MainView.m
  3. // day2
  4. //
  5. // Created by Axel Soedarsono on 8/30/17.
  6. // Copyright © 2017 Axel Soedarsono. All rights reserved.
  7. //
  8.  
  9. #import "MainView.h"
  10.  
  11. @interface MainView ()
  12.  
  13. @property (strong, nonatomic) UIView *informationImageView;
  14. @property (strong, nonatomic) UIView *informationDataView;
  15.  
  16. @property (strong, nonatomic) UIImageView *firstImageView;
  17.  
  18. @property (strong, nonatomic) UILabel *title1Label;
  19. @property (strong, nonatomic) UILabel *cityLabel;
  20. @property (strong, nonatomic) UILabel *temperatureLabel;
  21. @property (strong, nonatomic) UILabel *weatherLabel;
  22.  
  23. @property (strong, nonatomic) UITextField *inputTextField;
  24.  
  25. @property (strong, nonatomic) UIButton *usecurrentLocationButton;
  26.  
  27. @end
  28.  
  29. @implementation MainView
  30.  
  31. - (id)initWithFrame:(CGRect)frame{
  32. self = [super initWithFrame:frame];
  33.  
  34. if(self){
  35.  
  36. //set backgroundcolor
  37. self.backgroundColor = [UIColor lightGrayColor];
  38.  
  39. //view 1 -> imageView
  40. _informationImageView = [[UIView alloc] initWithFrame:CGRectMake(16.0f , 88.0f, CGRectGetWidth([UIScreen mainScreen].bounds) - 16.0f - 16.0f, 100.0f)];
  41.  
  42. self.informationImageView.backgroundColor = [UIColor darkGrayColor];
  43. self.informationImageView.layer.cornerRadius = CGRectGetHeight(self.informationImageView.frame)/2.0f;
  44. [self addSubview:self.informationImageView];
  45.  
  46. //image
  47. _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))];
  48.  
  49. self.firstImageView.image = [UIImage imageNamed: @"image"];
  50. self.firstImageView.contentMode = UIViewContentModeScaleAspectFill;
  51. self.firstImageView.layer.borderWidth = 5.0f;
  52. self.firstImageView.layer.borderColor = [UIColor whiteColor].CGColor;
  53. self.firstImageView.layer.cornerRadius = CGRectGetHeight(self.firstImageView.frame)/2.0f;
  54. self.firstImageView.clipsToBounds = YES;
  55. self.firstImageView.backgroundColor = [UIColor whiteColor];
  56. [self.informationImageView addSubview:self.firstImageView];
  57.  
  58. //title1Label
  59. _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)];
  60.  
  61. self.title1Label.text = @"WEATHER APP";
  62. self.title1Label.textColor = [UIColor whiteColor];
  63. self.title1Label.adjustsFontSizeToFitWidth = YES;
  64. self.title1Label.textAlignment = NSTextAlignmentCenter;
  65. self.title1Label.backgroundColor = [UIColor blackColor];
  66. [self addSubview:self.title1Label];
  67.  
  68. //inputTextField
  69. _inputTextField = [[UITextField alloc] initWithFrame:CGRectMake(24.0f, CGRectGetMaxY(self.title1Label.frame) + 16.0f, CGRectGetWidth([UIScreen mainScreen].bounds) - 24.0f - 24.0f, 24.0f)];
  70.  
  71. self.inputTextField.textColor = [UIColor blackColor];
  72. self.inputTextField.backgroundColor = [UIColor whiteColor];
  73. self.inputTextField.adjustsFontSizeToFitWidth = YES;
  74. self.inputTextField.textAlignment = NSTextAlignmentCenter;
  75. [self addSubview:self.inputTextField];
  76.  
  77. //useCurrentLocationBUtton
  78. _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)];
  79.  
  80. [self.usecurrentLocationButton setTitle:@"use current location" forState:UIControlStateNormal];
  81. [self.usecurrentLocationButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  82. self.usecurrentLocationButton.backgroundColor = [UIColor brownColor];
  83. [self addSubview:self.usecurrentLocationButton];
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. }
  92.  
  93. return self;
  94. }
  95.  
  96.  
  97. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement