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
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 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 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
// 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
// Add the below code in AppDelegate.swift inside of didFinishLaunchingWithOptions function | |
UINavigationBar.appearance().barTintColor = UIColor.white | |
UINavigationBar.appearance().isTranslucent = true | |
UINavigationBar.appearance().shadowImage = UIImage() | |
UINavigationBar.appearance().backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0) | |
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white] | |
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default) | |
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 | |
// WPML Language Selector | |
function io_language_selector( $english, $arabic ) { | |
if ( 'en' == ICL_LANGUAGE_CODE ) { | |
return $english; | |
} | |
elseif ( 'ar' == ICL_LANGUAGE_CODE ) { | |
return $arabic; | |
} |
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 | |
add_action( 'genesis_after_header', 'io_news_featured_news_post' ); | |
/** | |
* Outputs a custom loop with one features post | |
* | |
* @global mixed $paged current page number if paginated | |
* @return void | |
*/ | |
function io_news_featured_news_post() { |
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 | |
add_action( 'genesis_before_comments', 'io_related_posts' ); | |
function io_related_posts() { | |
$relatedPosts = get_field( 'related_posts' ); | |
if( $relatedPosts ): | |
echo '<div class="related-posts-container">'; | |
echo '<h3>Related Posts</h3>'; | |
echo '<ul class="related-posts">'; |
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 | |
/* Template Name: Testimonials */ | |
add_filter( 'body_class', 'io_body_class' ); | |
/** | |
* Adds a css class to the body element | |
* | |
* @param array $classes the current body classes | |
* @return array $classes modified classes |