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
//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
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
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
// | |
// ViewController.swift | |
// SendMailAttachment | |
// | |
// Created by Aman Aggarwal on 03/12/18. | |
// Copyright © 2018 Aman Aggarwal. All rights reserved. | |
// | |
import UIKit | |
import MessageUI |
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
import UIKit | |
import MessageUI | |
class ViewController: UIViewController, MFMailComposeViewControllerDelegate { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
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
@IBAction func sendEmail(_ sender: Any) { | |
if MFMailComposeViewController.canSendMail() { | |
let mailComposer = MFMailComposeViewController() | |
mailComposer.setSubject("Update about ios tutorials") | |
mailComposer.setMessageBody("What is the update about ios tutorials on youtube", isHTML: false) | |
mailComposer.setToRecipients(["[email protected]"]) | |
self.present(mailComposer, animated: true | |
, completion: nil) | |
} else { |
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
import MessageUI |
NewerOlder