Skip to content

Commit 90caf53

Browse files
committed
1 parent 7845c4c commit 90caf53

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

chapter-basics/Accepting User Text Input with UITextField/Accepting User Text Input with UITextField/ViewController.swift

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -163,36 +163,36 @@
163163
//}
164164

165165
/* 7 */
166-
//import UIKit
167-
//
168-
//class ViewController: UIViewController {
169-
//
170-
// var textField: UITextField!
171-
//
172-
// override func viewDidLoad() {
173-
// super.viewDidLoad()
174-
//
175-
// textField = UITextField(frame:
176-
// CGRect(x: 38, y: 30, width: 220, height: 31))
177-
//
178-
// textField.borderStyle = .RoundedRect
179-
// textField.contentVerticalAlignment = .Center
180-
// textField.textAlignment = .Left
181-
// textField.placeholder = "Enter your text here..."
182-
//
183-
// let currencyLabel = UILabel(frame: CGRectZero)
184-
// currencyLabel.text = NSNumberFormatter().currencySymbol
185-
// currencyLabel.font = textField.font
186-
// currencyLabel.textAlignment = .Right
187-
// currencyLabel.sizeToFit()
188-
// /* Give more width to the label so that it aligns properly on the
189-
// text field's left view, when the label's text itself is right aligned
190-
// */
191-
// currencyLabel.frame.size.width += 10
192-
// textField.leftView = currencyLabel
193-
// textField.leftViewMode = .Always
194-
// view.addSubview(textField)
195-
//
196-
// }
197-
//
198-
//}
166+
import UIKit
167+
168+
class ViewController: UIViewController {
169+
170+
var textField: UITextField!
171+
172+
override func viewDidLoad() {
173+
super.viewDidLoad()
174+
175+
textField = UITextField(frame:
176+
CGRect(x: 38, y: 30, width: 220, height: 31))
177+
178+
textField.borderStyle = .RoundedRect
179+
textField.contentVerticalAlignment = .Center
180+
textField.textAlignment = .Left
181+
textField.placeholder = "Enter your text here..."
182+
183+
let currencyLabel = UILabel(frame: CGRectZero)
184+
currencyLabel.text = NSNumberFormatter().currencySymbol
185+
currencyLabel.font = textField.font
186+
currencyLabel.textAlignment = .Right
187+
currencyLabel.sizeToFit()
188+
/* Give more width to the label so that it aligns properly on the
189+
text field's left view, when the label's text itself is right aligned
190+
*/
191+
currencyLabel.frame.size.width += 10
192+
textField.leftView = currencyLabel
193+
textField.leftViewMode = .Always
194+
view.addSubview(textField)
195+
196+
}
197+
198+
}

0 commit comments

Comments
 (0)