-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageTextView.swift
More file actions
47 lines (36 loc) · 1.59 KB
/
MessageTextView.swift
File metadata and controls
47 lines (36 loc) · 1.59 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
//
// MessageTextView.swift
// Cluster
//
// Created by Michael Fellows on 2/24/16.
// Copyright © 2016 ImagineME. All rights reserved.
//
import Foundation
class MessageTextView: UIView {
var textField: UITextField = UITextField.init()
var sendButton: UIButton = UIButton.init()
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .whiteColor()
let width = self.frame.size.width
let height = self.frame.size.height
let textFieldPadding = 5.0 as CGFloat
let buttonWidth = 60.0 as CGFloat
let textFieldWidth = width - (3 * textFieldPadding) - buttonWidth
let spacingView = UIView.init(frame: CGRectMake(0, 0, width, 1.0))
spacingView.backgroundColor = UIColor(white: 0.0, alpha: 0.1)
self.addSubview(spacingView)
let textFieldFrame = CGRectMake(textFieldPadding, textFieldPadding, textFieldWidth, height - (2 * textFieldPadding))
textField = UITextField.init(frame: textFieldFrame)
textField.placeholder = "Enter a message..."
self.addSubview(textField)
sendButton = UIButton.init(type: .Custom)
sendButton.setTitle("Send", forState: .Normal)
sendButton.frame = CGRectMake(textFieldWidth + (2 * textFieldPadding), textFieldPadding, buttonWidth, height - (2 * textFieldPadding))
sendButton.setTitleColor(.klusterPurpleColor(), forState: .Normal)
self.addSubview(sendButton)
}
required init?(coder aDecoder: NSCoder) {
super.init(frame: CGRectZero)
}
}