Skip to content

Instantly share code, notes, and snippets.

@asisadh
asisadh / UITextField
Created March 17, 2019 11:38
UITextField Extension
extension UITextField {
func underlined(){
let border = CALayer()
let width = CGFloat(2.0)
if let widthOfText = self.attributedText?.size().width{
border.borderColor = UIColor.primaryColor.cgColor
border.frame = CGRect(x: self.frame.size.width - widthOfText, y: self.frame.size.height - width, width: widthOfText, height: self.frame.size.height)
border.borderWidth = width
self.layer.addSublayer(border)
@asisadh
asisadh / ViewController
Created March 17, 2019 11:41
ViewController
class ViewController: UIViewController {
@IBOutlet weak var txtFieldDemo: UITextField! {
didSet{
txtFieldDemo.delegate = self
txtFieldDemo.addTarget(self, action: #selector(textFieldDidChange(textField:)), for: .editingChanged)
}
}
}
@asisadh
asisadh / AVAssetResourceLoaderDelegate+FairPlay.swift
Created July 4, 2019 09:45
FairPlay integration with Native AVPlayer Swift.
extension ViewController: AVAssetResourceLoaderDelegate{
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForRenewalOfRequestedResource renewalRequest: AVAssetResourceRenewalRequest) -> Bool {
return self.resourceLoader(resourceLoader, shouldWaitForLoadingOfRequestedResource: renewalRequest)
}
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
guard let url = loadingRequest.request.url else {
print("🔑", #function, "Unable to read the url/host data.")
loadingRequest.finishLoading(with: NSError(domain: "com.icapps.error", code: -1, userInfo: nil))
import UIKit
// MARK:- General Protocols
protocol ViewProtocol: class{
func showError(message: String)
func showLoading()
func hideLoading()
func refreshView()
}