Last active
April 9, 2019 17:40
-
-
Save Mintri1199/da5e4b856f5a28b507403107bb4db7bf to your computer and use it in GitHub Desktop.
view controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.title = "Hello Testing World" | |
setupTextField() | |
} | |
func vowelsInAString(string: String) -> Int { | |
let vowels: [Character] = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] | |
return string.reduce(0) { (initial, aCharacter) -> Int in | |
if vowels.contains(aCharacter) { | |
return initial + 1 | |
} else { | |
return initial | |
} | |
} | |
} | |
func makeTitle(string: String) -> String { | |
let words = string.components(separatedBy: " ") | |
// let headline = words.map { (word) -> String in | |
// return word.capitalized | |
// } | |
return string.capitalize // headline.joined(separator: " ") | |
} | |
var textField: UITextField = { | |
var view = UITextField(frame: .zero) | |
view.translatesAutoresizingMaskIntoConstraints = false | |
view.layer.borderWidth = 5 | |
view.layer.borderColor = UIColor.lightGray.cgColor | |
view.layer.cornerRadius = 10 | |
view.textAlignment = .center | |
view.placeholder = "Testing Placeholder" | |
return view | |
}() | |
private func setupTextField() { | |
view.addSubview(textField) | |
NSLayoutConstraint.activate([ | |
textField.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.1), | |
textField.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.5), | |
textField.centerXAnchor.constraint(equalTo: view.centerXAnchor), | |
textField.centerYAnchor.constraint(equalTo: view.centerYAnchor) | |
]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment