This file contains hidden or 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
// | |
// GetSnapshot+UIView.swift | |
// | |
extension UIView { | |
func getSnapshot() -> UIView? { | |
UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0) | |
guard let context = UIGraphicsGetCurrentContext() else { return nil } | |
// make an image from the pressed tableview cell |
This file contains hidden or 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
// | |
// Strikethrough+UILabel.swift | |
// | |
extension UILabel { | |
func strikethrough() { | |
if let string = self.text { | |
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: string) | |
attributeString.addAttribute(NSStrikethroughStyleAttributeName, value: 1, range: NSMakeRange(0, attributeString.length)) |
This file contains hidden or 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
// | |
// UIImageExtensions.swift | |
// | |
import CoreImage | |
extension UIImage { | |
func resizeImage(width: CGFloat, height: CGFloat) -> UIImage { | |
UIGraphicsBeginImageContext(CGSize(width: width, height: height)) |
This file contains hidden or 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
// | |
// UIColorExtensions.swift | |
// | |
import Foundation | |
extension UIColor { | |
// creates a color from a hex code example UIColor(hex: 0xFF0000) -> red | |
convenience init(hex: Int) { |
This file contains hidden or 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
// Tint+UIImageView.swift | |
extension UIImageView { | |
var tint: UIColor { | |
set { | |
self.image = self.image!.withRenderingMode(UIImageRenderingMode.alwaysTemplate) | |
self.tintColor = newValue | |
} | |
get { |
This file contains hidden or 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
// | |
// CustomView.swift | |
// | |
import UIKit | |
extension UIView { | |
// MARK: - Nib loading | |
public func loadNib() -> UIView { |
This file contains hidden or 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 | |
extension UIView { | |
func backgroundImage(named: String) { | |
let backgroundImage = UIImageView(frame: self.frame) | |
backgroundImage.image = UIImage(named: named) | |
backgroundImage.contentMode = .scaleAspectFill | |
backgroundImage.translatesAutoresizingMaskIntoConstraints = false | |
backgroundImage.center = self.center | |
backgroundImage.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin, .flexibleTopMargin, .flexibleBottomMargin] |
This file contains hidden or 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
// | |
// TextFieldMacAddress.swift | |
// | |
// Created by Peter Mukhortov on 01/11/2015. | |
// Copyright © 2015 Peter Mukhortov. All rights reserved. | |
// | |
// MAC address text field formatter for UITextField | |
// | |
import Foundation |
This file contains hidden or 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 UIImageView { | |
var tint: UIColor { | |
set { | |
self.image = self.image!.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) | |
self.tintColor = newValue | |
} | |
get { | |
return self.tint | |
} | |
} |
This file contains hidden or 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 hide() { | |
for constraint in self.constraints() as! [NSLayoutConstraint] { | |
if constraint.firstAttribute == NSLayoutAttribute.Height { | |
constraint.constant = 0 | |
} | |
} | |
} | |
func show() { |