Skip to content

Commit dc29e4e

Browse files
Update of the IBDesignable class and .podspec file
1 parent 64da45c commit dc29e4e

5 files changed

Lines changed: 35 additions & 52 deletions

File tree

Example/KWTextStyleLabel/AppDelegate.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
1515

16-
1716
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18-
// Override point for customization after application launch.
1917
return true
2018
}
2119

2220
func applicationWillResignActive(_ application: UIApplication) {
23-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24-
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
2521
}
2622

2723
func applicationDidEnterBackground(_ application: UIApplication) {
28-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
3024
}
3125

3226
func applicationWillEnterForeground(_ application: UIApplication) {
33-
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
3427
}
3528

3629
func applicationDidBecomeActive(_ application: UIApplication) {
37-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
3830
}
3931

4032
func applicationWillTerminate(_ application: UIApplication) {
41-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4233
}
43-
44-
4534
}
4635

Example/KWTextStyleLabel/Base.lproj/Main.storyboard

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,25 @@
2222
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2323
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2424
<subviews>
25-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tBY-1B-pbW" customClass="KWTextStyleLabel" customModule="KWTextStyleLabel">
26-
<rect key="frame" x="39" y="70" width="296" height="21"/>
25+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="characterWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tBY-1B-pbW" customClass="KWTextStyleLabel" customModule="KWTextStyleLabel">
26+
<rect key="frame" x="39" y="70" width="296" height="297"/>
2727
<constraints>
28-
<constraint firstAttribute="height" constant="21" id="dSU-6b-FVQ"/>
28+
<constraint firstAttribute="height" constant="297" id="dSU-6b-FVQ"/>
2929
</constraints>
3030
<fontDescription key="fontDescription" type="system" pointSize="17"/>
3131
<nil key="textColor"/>
3232
<nil key="highlightedColor"/>
33+
<userDefinedRuntimeAttributes>
34+
<userDefinedRuntimeAttribute type="number" keyPath="lineGap">
35+
<real key="value" value="6"/>
36+
</userDefinedRuntimeAttribute>
37+
<userDefinedRuntimeAttribute type="number" keyPath="characterSpacing">
38+
<real key="value" value="3"/>
39+
</userDefinedRuntimeAttribute>
40+
<userDefinedRuntimeAttribute type="string" keyPath="kerningText">
41+
<string key="value">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</string>
42+
</userDefinedRuntimeAttribute>
43+
</userDefinedRuntimeAttributes>
3344
</label>
3445
</subviews>
3546
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>

Example/KWTextStyleLabel/ViewController.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ class ViewController: UIViewController {
1818
override func viewDidLoad() {
1919
super.viewDidLoad()
2020

21-
test.characterSpacing = 1.4
22-
test.text = "Testing"
21+
test.characterSpacing = 3
22+
test.lineGap = 6
23+
test.text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
2324
}
24-
2525
}
26-

KWTextStyleLabel.podspec

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,18 @@
1-
#
2-
# Be sure to run `pod lib lint KWTextStyleLabel.podspec' to ensure this is a
3-
# valid spec before submitting.
4-
#
5-
# Any lines starting with a # are optional, but their use is encouraged
6-
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
7-
#
8-
91
Pod::Spec.new do |s|
102
s.name = 'KWTextStyleLabel'
113
s.version = '0.1.0'
12-
s.summary = 'A short description of KWTextStyleLabel.'
13-
14-
# This description is used to generate tags and improve search results.
15-
# * Think: What does it do? Why did you write it? What is the focus?
16-
# * Try to keep it short, snappy and to the point.
17-
# * Write the description between the DESC delimiters below.
18-
# * Finally, don't worry about the indent, CocoaPods strips it!
4+
s.summary = 'Subclass of UILabel to modify character spacing and line spacing to your label.'
195

206
s.description = <<-DESC
21-
TODO: Add long description of the pod here.
7+
Helps in modifying character spacing and line spacing to your label. You can modify using storyboard (Text Style Label) or programmatically.
228
DESC
239

24-
s.homepage = 'https://github.com/<GITHUB_USERNAME>/KWTextStyleLabel'
25-
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
10+
s.homepage = 'https://github.com/keepworks/KWTextStyleLabel'
2611
s.license = { :type => 'MIT', :file => 'LICENSE' }
27-
s.author = { 'Vinoth Anandan' => 'vinoth@keepworks.com' }
28-
s.source = { :git => 'https://github.com/<GITHUB_USERNAME>/KWTextStyleLabel.git', :tag => s.version.to_s }
29-
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
12+
s.author = { 'Vinoth Anandan S' => 'vinoth@keepworks.com' }
13+
s.source = { :git => 'https://github.com/keepworks/KWTextStyleLabel.git', :tag => s.version.to_s }
3014

3115
s.ios.deployment_target = '8.0'
32-
3316
s.source_files = 'KWTextStyleLabel/Classes/**/*'
3417

35-
# s.resource_bundles = {
36-
# 'KWTextStyleLabel' => ['KWTextStyleLabel/Assets/*.png']
37-
# }
38-
39-
# s.public_header_files = 'Pod/Classes/**/*.h'
40-
# s.frameworks = 'UIKit', 'MapKit'
41-
# s.dependency 'AFNetworking', '~> 2.3'
4218
end

KWTextStyleLabel/Classes/KWTextStyleLabel.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88

99
import UIKit
1010

11-
open class KWTextStyleLabel: UILabel {
12-
13-
// MARK: - Variables
14-
open var characterSpacing = 1.25
15-
open var lineGap: CGFloat = 0
11+
@IBDesignable open class KWTextStyleLabel: UILabel {
1612

1713
// MARK: - IBInspectables
14+
@IBInspectable open var characterSpacing: CGFloat = 0 {
15+
didSet {
16+
text = kerningText
17+
}
18+
}
19+
20+
@IBInspectable open var lineGap: CGFloat = 0 {
21+
didSet {
22+
text = kerningText
23+
}
24+
}
25+
1826
@IBInspectable var kerningText: String = "" {
1927
didSet {
2028
text = kerningText

0 commit comments

Comments
 (0)