feat: Add class to add padding on UILabel
This commit is contained in:
@@ -130,6 +130,7 @@
|
||||
DCAB01E524CEC12E00E8B54C /* MenuHeaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAB01E424CEC12E00E8B54C /* MenuHeaderTableViewCell.swift */; };
|
||||
DCAB01E724CEC22100E8B54C /* MenuItemTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAB01E624CEC22100E8B54C /* MenuItemTableViewCell.swift */; };
|
||||
DCB6FBEC24D0B40600ED23B8 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DCB6FBEB24D0B40600ED23B8 /* Colors.xcassets */; };
|
||||
DCC23DEF24D28F58003A2404 /* EQNEdgeInsetLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC23DEE24D28F58003A2404 /* EQNEdgeInsetLabel.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -355,6 +356,7 @@
|
||||
DCAB01E424CEC12E00E8B54C /* MenuHeaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuHeaderTableViewCell.swift; sourceTree = "<group>"; };
|
||||
DCAB01E624CEC22100E8B54C /* MenuItemTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemTableViewCell.swift; sourceTree = "<group>"; };
|
||||
DCB6FBEB24D0B40600ED23B8 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
|
||||
DCC23DEE24D28F58003A2404 /* EQNEdgeInsetLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNEdgeInsetLabel.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -538,6 +540,7 @@
|
||||
8CBD3DCE2149B9AD0070C963 /* Earthquake_Network.xcdatamodeld */,
|
||||
DCB6FBEA24D0B11300ED23B8 /* Controllers */,
|
||||
DCB6FBE924D0B0DF00ED23B8 /* Models */,
|
||||
DCC23DED24D28F41003A2404 /* UI */,
|
||||
DC3ADD3024CB1F1E00737919 /* Storyboards */,
|
||||
DC3ADD2F24CB1EFB00737919 /* Libs */,
|
||||
DC3ADD2D24CB1EAF00737919 /* Resources */,
|
||||
@@ -774,6 +777,14 @@
|
||||
path = Controllers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
DCC23DED24D28F41003A2404 /* UI */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DCC23DEE24D28F58003A2404 /* EQNEdgeInsetLabel.swift */,
|
||||
);
|
||||
path = UI;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -1029,6 +1040,7 @@
|
||||
files = (
|
||||
8CF05B54218C41FB0055012B /* TBDInputViewControllerData.m in Sources */,
|
||||
8CCE166121EBA37500173CD9 /* EQNNotificheTsunami.m in Sources */,
|
||||
DCC23DEF24D28F58003A2404 /* EQNEdgeInsetLabel.swift in Sources */,
|
||||
DCAB01E524CEC12E00E8B54C /* MenuHeaderTableViewCell.swift in Sources */,
|
||||
8C483CCD21FDB52500259FD2 /* MasterViewController1.swift in Sources */,
|
||||
8CCE165121E7BAEC00173CD9 /* EQNNotificeReteSismiche.m in Sources */,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// EQNEdgeInsetLabel.swift
|
||||
// Earthquake Network
|
||||
//
|
||||
// Created by Busi Andrea on 30/07/2020.
|
||||
// Copyright © 2020 Earthquake Network. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
class EQNEdgeInsetLabel: UILabel {
|
||||
var textInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 15) {
|
||||
didSet { invalidateIntrinsicContentSize() }
|
||||
}
|
||||
|
||||
override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
|
||||
let insetRect = bounds.inset(by: textInsets)
|
||||
let textRect = super.textRect(forBounds: insetRect, limitedToNumberOfLines: numberOfLines)
|
||||
let invertedInsets = UIEdgeInsets(top: -textInsets.top,
|
||||
left: -textInsets.left,
|
||||
bottom: -textInsets.bottom,
|
||||
right: -textInsets.right)
|
||||
return textRect.inset(by: invertedInsets)
|
||||
}
|
||||
|
||||
override func drawText(in rect: CGRect) {
|
||||
super.drawText(in: rect.inset(by: textInsets))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user