forked from Awful/Awful.app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAwfulComposeField.m
More file actions
52 lines (42 loc) · 1.46 KB
/
AwfulComposeField.m
File metadata and controls
52 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// AwfulComposeField.m
// Awful
//
// Created by Nolan Waite on 2013-03-01.
// Copyright (c) 2013 Regular Berry Software LLC. All rights reserved.
//
#import "AwfulComposeField.h"
@interface AwfulComposeField ()
@property (nonatomic) UILabel *label;
@property (nonatomic) UITextField *textField;
@end
@implementation AwfulComposeField
#pragma mark - UIView
- (id)initWithFrame:(CGRect)frame
{
if (!(self = [super initWithFrame:frame])) return nil;
_label = [UILabel new];
_label.textColor = [UIColor grayColor];
_label.font = [UIFont systemFontOfSize:16];
[self addSubview:_label];
_textField = [UITextField new];
_textField.font = [UIFont systemFontOfSize:16];
[self addSubview:_textField];
return self;
}
- (void)layoutSubviews
{
self.label.frame = (CGRect){ .size.height = CGRectGetHeight(self.frame) - 1 };
[self.label sizeToFit];
self.label.center = CGPointMake(0, CGRectGetHeight(self.frame) / 2);
CGRect labelFrame = self.label.frame;
labelFrame.origin.x = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 19 : 8;
self.label.frame = labelFrame;
CGRect textFieldFrame = self.textField.frame;
textFieldFrame.origin.y = labelFrame.origin.y;
textFieldFrame.origin.x = CGRectGetMaxX(labelFrame) + 11;
textFieldFrame.size.width = CGRectGetWidth(self.frame) - CGRectGetMinX(textFieldFrame);
textFieldFrame.size.height = labelFrame.size.height;
self.textField.frame = textFieldFrame;
}
@end