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
extension UITapGestureRecognizer { | |
func didTapAttributedTextInLabel(label: UILabel, inRange targetRange: NSRange) -> Bool { | |
// Create instances of NSLayoutManager, NSTextContainer and NSTextStorage | |
let layoutManager = NSLayoutManager() | |
let textContainer = NSTextContainer(size: CGSize.zero) | |
let textStorage = NSTextStorage(attributedString: label.attributedText!) | |
// Configure layoutManager and textStorage | |
layoutManager.addTextContainer(textContainer) |
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:- tappedOnLabel | |
@objc func tappedOnLabel(_ gesture: UITapGestureRecognizer) { | |
guard let text = self.lblTermsAndConditions.text else { return } | |
let privacyPolicyRange = (text as NSString).range(of: "privacy policy") | |
let termsAndConditionRange = (text as NSString).range(of: "terms and condition") | |
if gesture.didTapAttributedTextInLabel(label: self.lblTermsAndConditions, inRange: privacyPolicyRange) { | |
print("user tapped on privacy policy text") | |
} else if gesture.didTapAttributedTextInLabel(label: self.lblTermsAndConditions, inRange: termsAndConditionRange){ | |
print("user tapped on terms and conditions text") | |
} |
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
self.lblTermsAndConditions.isUserInteractionEnabled = true | |
let tapgesture = UITapGestureRecognizer(target: self, action: #selector(tappedOnLabel(_ :))) | |
tapgesture.numberOfTapsRequired = 1 | |
self.lblTermsAndConditions.addGestureRecognizer(tapgesture) |
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 { | |
var employeeArray:[Dictionary<String, AnyObject>] = Array() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
for i in 1...10 { | |
var dct = Dictionary<String, AnyObject>() | |
dct.updateValue(i as AnyObject, forKey: "EmpID") | |
dct.updateValue("NameForEmplyee id = \(i)" as AnyObject, forKey: "EmpName") |
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 animatePulsatingLayerAt(index:Int) { | |
//Giving color to the layer | |
pulseArray[index].strokeColor = UIColor.darkGray.cgColor | |
//Creating scale animation for the layer, from and to value should be in range of 0.0 to 1.0 | |
// 0.0 = minimum | |
//1.0 = maximum | |
let scaleAnimation = CABasicAnimation(keyPath: "transform.scale") | |
scaleAnimation.fromValue = 0.0 |
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
// | |
// ViewController.swift | |
// addCheckBoxonTable-Tutorial | |
// | |
// Created by Aman Aggarwal on 2/1/18. | |
// Copyright © 2018 iostutorialjunction.com. All rights reserved. | |
// | |
import UIKit | |
class ViewController: UIViewController, UITableViewDataSource { |
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 getImageFromBase64(base64:String) -> UIImage { | |
let data = Data(base64Encoded: base64) | |
return UIImage(data: data!)! | |
} |
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
UNUserNotificationCenter.current().delegate = self | |
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in | |
if granted { | |
print("User gave permissions for local notifications") | |
} | |
} |
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
self.cntView.layer.cornerRadius = 13.0 | |
self.cntView.layer.shadowColor = UIColor.lightGray.cgColor | |
self.cntView.layer.shadowOpacity = 0.5 | |
self.cntView.layer.shadowRadius = 10.0 | |
self.cntView.layer.shadowOffset = .zero | |
self.cntView.layer.shadowPath = UIBezierPath(rect: self.cntView.bounds).cgPath | |
self.cntView.layer.shouldRasterize = true | |
//Note:- cntView is an IBOutlet |
NewerOlder