Skip to content

Instantly share code, notes, and snippets.

View muratyasarr's full-sized avatar
🎯
Focusing

Murat Yasar muratyasarr

🎯
Focusing
View GitHub Profile
class LabelWithPadding: UILabel {
@objc var padding = UIEdgeInsets.zero {
didSet { invalidateIntrinsicContentSize() }
}
@IBInspectable public var bottomInset: CGFloat {
get { return padding.bottom }
set { padding.bottom = newValue }
}
static func compressImage(image:UIImage) -> Data? {
// Reducing file size to a 10th
var actualHeight: CGFloat = image.size.height
var actualWidth: CGFloat = image.size.width
let maxHeight: CGFloat = 1136.0
let maxWidth: CGFloat = 640.0
var imgRatio: CGFloat = actualWidth/actualHeight
let maxRatio: CGFloat = maxWidth/maxHeight
var compressionQuality: CGFloat = 0.7