Simple app for beginners. Nuked Code [0]
The code has been nuked. There is the pilot video on my channel. In this video you will learn how to make a simple app for iOS by using Swift 5 and Xcode. Also this video covers the basic information about constants and variables, Xcode interface and NSAttributedString or attributed, coloured text as a bonus. 12 minutes of puuuuure content.
Used code:
import UIKit class ViewController: UIViewController { @IBOutlet weak var messagesLabel: UILabel! @IBOutlet weak var messageTextField: UITextField! var messages = NSMutableAttributedString() let firstAttribute: [NSAttributedString.Key : Any] = [.foregroundColor : UIColor.blue] let secondAttribute: [NSAttributedString.Key : Any] = [.foregroundColor : UIColor.purple] var useFirstAttribute: Bool = true override func viewDidLoad() { super.viewDidLoad() messagesLabel.text = nil // Do any additional setup after loading the view. } @IBAction func sendMessageButtonTouched(_ sender: UIButton) { if let textFromField = messageTextField.text{ messages.append(NSAttributedString(string: "\n\n" + textFromField, attributes: useFirstAttribute ? firstAttribute : secondAttribute)) messagesLabel.attributedText = messages } useFirstAttribute = !useFirstAttribute messageTextField.text = nil } } |
The code has been highlighted by Swiftlighter
Comments