if UserDefaults.standard.object(forKey: "country") != nil {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let rootVC = storyboard.instantiateViewController(withIdentifier: "TabBarController") as? UITabBarController
window?.rootViewController = rootVC
}
UIWindow
. В этом классе настраиваются все основные потребности вашего приложения, будь то Push Notifications или Voice Calls и так далее. Я бы сказал это Core вашего приложения.UIResponder
и UIApplicationDelegate
An abstract interface for responding to and handling events.
A set of methods that are called by the singleton UIApplication object in response to important events in the lifetime of your app.
@IBAction func buttonPressed(_ sender: UIButton) { ... }
есть аргумент sender
по которому Вы и можете различать какая именно кнопка вызвала этот action. А вообще бы лучше основную свою задачу описали, а то так не очень понятно что Вы хотите. Зачем Вам findById( findByClass ) ? Для этого есть IBOutlets
. Если Вы ищите кнопку среди subviews
, то тут можно приводить каждый subview
к типу UIButton
(если это возможно) и смотреть скажем его title
или смотреть его RestorationID. UISearchController
, а обычный UISearchBar
c кастомным аниматором UIViewPropertyAnimator
. 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.
}
}
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.
}
}
There will not be any difference between loading web view from loadRequest vs loadHTMLString method, shouldStartLoadWithRequest method will be called in both cases. You can override your headers there and add header as per your requirements.