Skip to content

Instantly share code, notes, and snippets.

@numanayhan
Last active June 12, 2020 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save numanayhan/234f1b2fdabbdf52d80cedc83701a3b8 to your computer and use it in GitHub Desktop.
Save numanayhan/234f1b2fdabbdf52d80cedc83701a3b8 to your computer and use it in GitHub Desktop.
Label
import UIKit
class LabelCtrl: UIViewController {
//Sürükle bırak ile tanımladım ve Sayfaya bağladım.
@IBOutlet weak var textLabel: UILabel!
//Lazy ile kodlama ile tanıpladım
lazy var metin : UILabel = {
var label = UILabel()
label.text = " Created by HR on 1.11.2020. Copyright © 2019 hrdijital. All rights reserved."
label.textAlignment = .center
label.textColor = .red
label.lineBreakMode = .byWordWrapping
label.adjustsFontSizeToFitWidth = true
label.isUserInteractionEnabled = true
label.numberOfLines = 0
label.backgroundColor = UIColor.init(red: 240, green: 240, blue: 240, alpha: 1.0)
return label
}()
override func viewDidLoad() {
super.viewDidLoad()
//textLabel içine kodlama ile de metin girilebilir
textLabel.text = "UILabel ile Metin"
metin.frame = CGRect(x: 0, y: 0, width: 240.0, height:100)
view.addSubview(metin)
metin.center = view.center
}
func addBottomBorder(_ uiView:UIView , borderWidth: CGFloat) ->UIView {
uiView.autoresizingMask = [.flexibleWidth, .flexibleTopMargin]
uiView.frame = CGRect(x: 0, y: view.frame.height - borderWidth, width: view.frame.width, height: borderWidth)
return uiView
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment