Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  FloatBox.m
  3. //  Jell
  4. //
  5. //  Created by Admin on 9/15/14.
  6. //  Copyright (c) 2014 ___LEZGRO___. All rights reserved.
  7. //
  8.  
  9. #import "FloatBox.h"
  10.  
  11. @implementation FloatBox
  12.  
  13. - (instancetype)initWithFrame:(CGRect)frame
  14.                         title:(NSString *)title
  15.                      subTitle:(NSString *)subTitle
  16. {
  17.     self = [self initWithFrame:frame];
  18.     if (self) {
  19.  
  20.         CGFloat titleLabelHeight = 20.0;
  21.         CGFloat subTitleLabelOfsetY = 20.0;
  22.         CGFloat fontSize = 10.0;
  23.         CGFloat floatBoxBorderWidth = 1.0;
  24.  
  25.         self.backgroundColor = [UIColor whiteColor];
  26.         UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), titleLabelHeight)];
  27.         titleLabel.text = title;
  28.         titleLabel.font = [UIFont systemFontOfSize:fontSize];
  29.         titleLabel.textAlignment = NSTextAlignmentCenter;
  30.         titleLabel.textColor = [UIColor greenColor];
  31.  
  32.         UILabel *subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, subTitleLabelOfsetY, CGRectGetWidth(self.frame), titleLabelHeight)];
  33.         subTitleLabel.text = subTitle;
  34.         subTitleLabel.font = [UIFont systemFontOfSize:fontSize];
  35.         subTitleLabel.textAlignment = NSTextAlignmentCenter;
  36.         titleLabel.textColor = [UIColor greenColor];
  37.  
  38.         [self addSubview:titleLabel];
  39.         [self addSubview:subTitleLabel];
  40.         [self.layer setBorderColor:[UIColor greenColor].CGColor];
  41.         [self.layer setBorderWidth:floatBoxBorderWidth];
  42.         [self sizeToFit];
  43.     }
  44.     return self;
  45. }
  46.  
  47. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement