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
// Create a new file called extension and add the following code to it | |
extension UIColor { | |
static func rgb(red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor { | |
return UIColor(red: red/255, green: green/255, blue: blue/255, alpha: 1) | |
} | |
} |
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 UIView { | |
func anchor(top: NSLayoutYAxisAnchor?, leading: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, trailing: NSLayoutXAxisAnchor?, paddingTop: CGFloat, paddingLeading: CGFloat, paddingBottom: CGFloat, paddingTrailing: CGFloat, width: CGFloat, height: CGFloat) { | |
translatesAutoresizingMaskIntoConstraints = false | |
if let top = top { | |
self.topAnchor.constraint(equalTo: top, constant: paddingTop).isActive = true | |
} | |
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 UIColor { | |
static func rgb(red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor { | |
return UIColor(red: red/255, green: green/255, blue: blue/255, alpha: 1) | |
} | |
static func mainColor() -> UIColor { | |
return UIColor.rgb(red: 105, green: 26, blue: 64) | |
} | |
static func UIColorFromHex(rgbValue:UInt32, alpha:Double=1.0)->UIColor { |
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 UIImage { | |
func resizeWithPercent(percentage: CGFloat) -> UIImage? { | |
let imageView = UIImageView(frame: CGRect(origin: .zero, size: CGSize(width: size.width * percentage, height: size.height * percentage))) | |
imageView.contentMode = .scaleAspectFit | |
imageView.image = self | |
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, scale) | |
guard let context = UIGraphicsGetCurrentContext() else { return nil } | |
imageView.layer.render(in: context) | |
guard let result = UIGraphicsGetImageFromCurrentImageContext() else { return nil } | |
UIGraphicsEndImageContext() |
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 UIActivityIndicatorView { | |
static func startActivityIndicator(base: UIViewController, indicator: UIActivityIndicatorView, container: UIView, loadingView: UIView) { | |
container.frame = base.view.frame | |
container.center = base.view.center | |
container.backgroundColor = UIColor.UIColorFromHex(rgbValue: 0xffffff, alpha: 0.3) | |
loadingView.frame = CGRect(x: 0, y: 0, width: 80, height: 80) | |
loadingView.center = base.view.center | |
loadingView.backgroundColor = UIColor.UIColorFromHex(rgbValue: 0x444444, alpha: 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
<?php | |
// Only add the content below this line | |
add_filter('body_class','browser_body_class'); | |
/** | |
* | |
* Add browser class based on user browser | |
* | |
*/ | |
function browser_body_class($classes) { |
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 PdfTools { | |
func generatePdfFromCollectionView(_ collectionView: UICollectionView?, filename:String, success:(String) -> ()) { | |
guard let collectionView = collectionView else { | |
return | |
} | |
let pdfData = NSMutableData() | |
let contentArea = CGRect( |
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
// Here you can set View width and height as per your requirement for displaying supportView position in navigationbar | |
let supportView = UIView(frame: CGRect(x: 0, y: 0, width: 120, height: 40)) | |
//supportView.backgroundColor = UIColor.red | |
let logo = UIImageView(image: UIImage(named: "logo")) //UIImage(named: "SelectAnAlbumTitleLettering") | |
// customize the origin as (45,5) but can pass them as your requirement. | |
logo.frame = CGRect(x: 0, y: -5, width: supportView.frame.size.width, height: supportView.frame.size.height) | |
supportView.addSubview(logo) | |
supportView.contentMode = .center |
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: - Firebase Auth | |
extension Auth { | |
//Handle Firebase Auth Errors | |
static func handleFirebaseAuthErrorWith(errorCode: AuthErrorCode) -> [String] { | |
switch errorCode { | |
case .emailAlreadyInUse: | |
let title = "User Exist" | |
let message = "The email address provided already exist. Please login using your credentials." | |
return [title, message] | |
case .invalidEmail: |
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 attributedString = NSMutableAttributedString(string: "WhatEver text you want") | |
// *** Create instance of `NSMutableParagraphStyle` | |
let paragraphStyle = NSMutableParagraphStyle() | |
// *** set LineSpacing property in points *** | |
paragraphStyle.lineSpacing = 4 // Whatever line spacing you want in points | |
// *** Apply attribute to string *** | |
attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) |