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
public func GetLabelHeight(text:String, font:UIFont, width:CGFloat) -> CGFloat { | |
let label:UILabel = UILabel(frame: CGRect(x: 0, y: 0, width: width, height: CGFloat.greatestFiniteMagnitude)) | |
label.numberOfLines = 0 | |
label.lineBreakMode = NSLineBreakMode.byWordWrapping | |
label.font = font | |
label.text = text | |
label.sizeToFit() | |
return label.frame.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
import UIKit | |
public func GetImageSize(url:URL) -> (width: CGFloat, height: CGFloat) { | |
var imageWidth:CGFloat = 0 | |
var imageHeight:CGFloat = 0 | |
if let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) { | |
if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary? { | |
imageWidth = imageProperties[kCGImagePropertyPixelWidth] as! CGFloat | |
imageHeight = imageProperties[kCGImagePropertyPixelHeight] as! 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
@mixin fancy-hover($sprite_dir, $off_state, $hover_state, $speed: 0.3s) | |
$sprites: sprite-map("#{$sprite_dir}/*.png") | |
$width: image-width(sprite_file($sprites, $off_state)) | |
$height: image-height(sprite_file($sprites, $off_state)) | |
@include hide-text | |
width: $width | |
height: $height | |
background: sprite($sprites, $off_state) no-repeat | |
display: block | |
position: relative |