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
.rotate(@val) { | |
-moz-transform: rotate(@val); /* FF3.5+ */ | |
-o-transform: rotate(@val); /* Opera 10.5 */ | |
-webkit-transform: rotate(@val); /* Saf3.1+, Chrome */ | |
-ms-transform: rotate(@val); /* IE9 */ | |
transform: rotate(@val); | |
/* IE6-IE8 */ | |
@radians: ~`parseInt("@{val}") * Math.PI * 2 / 360`; | |
@costheta: ~`Math.cos("@{radians}")`; |
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 resizeX(width: CGFloat) { | |
for constraint in self.constraints() as! [NSLayoutConstraint] { | |
if constraint.firstAttribute == NSLayoutAttribute.Width { | |
constraint.constant = width | |
} | |
} | |
} | |
func resizeY(height: CGFloat) { |
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() { |
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
// | |
// 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
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
// | |
// 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
// 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
// | |
// 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
// | |
// UIImageExtensions.swift | |
// | |
import CoreImage | |
extension UIImage { | |
func resizeImage(width: CGFloat, height: CGFloat) -> UIImage { | |
UIGraphicsBeginImageContext(CGSize(width: width, height: height)) |
OlderNewer