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
CATransaction.begin() //Start of animation transaction | |
CATransaction.setCompletionBlock { //Transaction is Ready | |
print("READY") | |
} | |
heightConstraint.constant = 80.0 | |
UIView.animate(withDuration: 2.0) { // UIView type of animation | |
view.layoutIfNeeded() |
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
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Creation of View | |
let square = UIView(frame: CGRect(x: 20, y: 70, width: 370, height: 200)) | |
square.layer.borderColor = UIColor.green.cgColor | |
square.layer.borderWidth = 2.0 | |
square.layer.cornerRadius = 5 | |
square.backgroundColor = UIColor.systemPink |
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
let rect = CGRect(x: 40, y: 40, width: 300, height: 250) | |
let view = UIView(frame: rect) | |
view.backgroundColor = UIColor.systemPink | |
//Add Shadow | |
view.layer.shadowColor = UIColor.red.cgColor | |
view.layer.shadowOffset = CGSize(width: 20, height: 20) | |
view.layer.shadowRadius = 10.0 | |
view.layer.shadowOpacity = 0.7 |
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
// MARK: Creation of sublayer1 | |
let sublayer1 = CALayer() | |
sublayer1.frame = CGRect(x: 20, y: 20, width: 30, height: 30) | |
sublayer1.backgroundColor = UIColor.red.cgColor | |
// MARK: Creation of sublayer2 | |
let sublayer2 = CALayer() | |
sublayer2.frame = CGRect(x: 80, y: 80, width: 40, height: 40) | |
sublayer2.backgroundColor = UIColor.green.cgColor |
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
//We can change preferredStyle: .actionSheet | |
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert) | |
//Add Cancel Action | |
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil) | |
//Add Default Action | |
alert.addAction(UIAlertAction(title: "Default", style: .default, handler: { (action) in | |
print("Default action") | |
})) |
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
func openAlert() { | |
//UITextField completionHandler. Here we can customize and add event handlers to field | |
alert.addTextField { (field) in | |
field.placeholder = "Pet Name" //add placeholder | |
field.addTarget(self, action: #selector(self.editingChanged), for: .editingChanged) //add editingChanged handler | |
} | |
self.present(alert, animated: true, completion: nil) | |
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
//We can change preferredStyle: .actionSheet | |
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert) | |
//Add Cancel Action | |
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)) | |
//Add Default Action | |
alert.addAction(UIAlertAction(title: "Default", style: .default, handler: { action in | |
print("Default button did tap") | |
})) |
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
func runReportFlow() { | |
func getWeekReportBody() {} //First Nested Function | |
func getMonthReportBody() {} //Second Nested Function | |
if isSomeConditionTrue { | |
getWeekReportBody() | |
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
class Factory { | |
var car: Car | |
init(car: Car) { | |
self.car = car | |
} | |
deinit { | |
print("Factory model deallocated") |
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
class HalfCircleIndicator: UIView { | |
private var progressLayer: CAShapeLayer! | |
private var fullSize: CGSize! | |
private var grayCircleSize: CGSize! | |
private var innerGrayCircleSize: CGSize! | |
private var greenCircleSize: CGSize! | |
var value: CGFloat = 0.0 | |
var isInnerCircleExist: Bool |