Skip to content

Instantly share code, notes, and snippets.

@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
@timjackleus
timjackleus / GetImageSizeByUrl.swift
Created October 20, 2017 08:41
Get with and height of image by url
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
@timjackleus
timjackleus / GetLabelSizeByUrl.swift
Created October 20, 2017 08:43
Get height of label by font and width
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
}