Дисклеймер: Не изобретайте велосипед!
func application(
_ application: UIApplication,
willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
// ...
return true
}
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// ...
return true
}
AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
// ...
}
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
private var substrateView = UIView()
private var substrateLabel = UILabel()
private var constraint = NSLayoutConstraint()
@IBAction func someAction(_ sender: Any) {
substrateView.isHidden = false
UIView.animate(withDuration: 0.3) { [unowned self] in
self.constraint.isActive = false
self.constraint = self.substrateView.heightAnchor.constraint(equalToConstant: 60)
self.constraint.isActive = true
self.view.layoutIfNeeded()
}
}
override func viewDidLoad() {
super.viewDidLoad()
textField.layer.borderWidth = 3
textField.layer.borderColor = UIColor(red: 233/255, green: 128/255, blue: 129/255, alpha: 1).cgColor
textField.layer.cornerRadius = 8
substrateView.backgroundColor = UIColor(red: 233/255, green: 128/255, blue: 129/255, alpha: 1)
substrateView.layer.cornerRadius = 8
substrateLabel.text = "Login is not valid"
substrateLabel.textAlignment = .center
substrateLabel.textColor = UIColor.white
substrateLabel.backgroundColor = UIColor.clear
substrateView.addSubview(substrateLabel)
substrateLabel.translatesAutoresizingMaskIntoConstraints = false
substrateLabel.frame = CGRect.zero
substrateLabel.sizeToFit()
substrateLabel.bottomAnchor.constraint(equalTo: substrateView.bottomAnchor).isActive = true
substrateLabel.centerXAnchor.constraint(equalTo: substrateView.centerXAnchor).isActive = true
view.addSubview(substrateView)
substrateView.translatesAutoresizingMaskIntoConstraints = false
substrateView.topAnchor.constraint(equalTo: textField.topAnchor).isActive = true
substrateView.leftAnchor.constraint(equalTo: textField.leftAnchor).isActive = true
substrateView.rightAnchor.constraint(equalTo: textField.rightAnchor).isActive = true
substrateView.widthAnchor.constraint(equalTo:textField.widthAnchor).isActive = true
constraint = substrateView.heightAnchor.constraint(equalTo: textField.heightAnchor)
constraint.isActive = true
textField.layer.zPosition = 1
substrateView.isHidden = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
id | name | parent_id
1 | Спорт | null
2 | Футбол | 1
3 | Чемпионат РФПЛ | 2
id | tree_id | data
1 | 3 | Инфа о чемпионате РФПЛ
select * from data where tree_id=3
UIView.layer.shadowPath
.import UIKit
@IBDesignable
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
textField.layer.shadowColor = UIColor.purple.cgColor
textField.layer.cornerRadius = 8
textField.layer.masksToBounds = false
textField.layer.shadowOffset = CGSize.zero
textField.layer.shadowRadius = 3.0
textField.layer.shadowOpacity = 0.7
let path = UIBezierPath()
path.move(to: CGPoint(x: 0.0, y: 0.0))
path.addLine(to: CGPoint(x: textField.bounds.size.width/2, y: textField.bounds.size.height/2))
path.addLine(to: CGPoint(x: textField.bounds.maxX, y: 0.0))
path.addLine(to: CGPoint(x: textField.bounds.maxX, y: textField.bounds.maxY))
path.addLine(to: CGPoint(x: 0.0, y: textField.bounds.maxY))
path.close()
textField.layer.shadowPath = path.cgPath
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}