You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
985 B
30 lines
985 B
//
|
|
// LabelExtension.swift
|
|
// GMERemittance
|
|
//
|
|
// Created by Sujal on 3/2/18.
|
|
// Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
|
|
// Creates a padding to the left and right of the label with a value of 5
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class PaddedLabel : UILabel
|
|
{
|
|
var edgeInsets:UIEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
|
|
|
|
override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
|
|
var rect = super.textRect(forBounds: UIEdgeInsetsInsetRect(bounds, edgeInsets), limitedToNumberOfLines: numberOfLines)
|
|
|
|
rect.origin.x -= edgeInsets.left
|
|
rect.origin.y -= edgeInsets.top
|
|
rect.size.width += (edgeInsets.left + edgeInsets.right);
|
|
rect.size.height += (edgeInsets.top + edgeInsets.bottom);
|
|
|
|
return rect
|
|
}
|
|
|
|
override func drawText(in rect: CGRect) {
|
|
super.drawText(in: UIEdgeInsetsInsetRect(rect, edgeInsets))
|
|
}
|
|
}
|