Skip to content

Commit 01c1861

Browse files
committed
Added an example how to use textRange
1 parent b6b6531 commit 01c1861

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

MZTimerLabelDemo/MZTimerLabelDemo/DemoView.xib

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
33
<dependencies>
44
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
66
</dependencies>
77
<objects>
88
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MZTLViewController">
@@ -15,6 +15,7 @@
1515
<outlet property="lblTimerExample10" destination="vzH-hb-brN" id="F32-P4-h1O"/>
1616
<outlet property="lblTimerExample11" destination="ACP-7x-O0o" id="1pn-7N-LkO"/>
1717
<outlet property="lblTimerExample12" destination="6qi-SI-U5U" id="Ise-2j-z3W"/>
18+
<outlet property="lblTimerExample13" destination="TBf-ji-c4u" id="Bvo-9j-VCG"/>
1819
<outlet property="lblTimerExample3" destination="ieJ-p1-t8W" id="xcG-S9-94E"/>
1920
<outlet property="lblTimerExample4" destination="i60-gF-36n" id="s82-xv-4Nu"/>
2021
<outlet property="lblTimerExample5" destination="jZs-y9-Hiw" id="FkR-Os-Zx7"/>
@@ -27,7 +28,7 @@
2728
</placeholder>
2829
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
2930
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" indicatorStyle="black" id="516-pT-IPn">
30-
<rect key="frame" x="0.0" y="0.0" width="320" height="1531"/>
31+
<rect key="frame" x="0.0" y="0.0" width="320" height="1619"/>
3132
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
3233
<subviews>
3334
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00:00" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Jro-es-Ovt" customClass="MZTimerLabel">
@@ -297,21 +298,21 @@
297298
<nil key="highlightedColor"/>
298299
</label>
299300
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="MZTimerLabel by mineschan@github" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="VNu-yQ-5Ud">
300-
<rect key="frame" x="49" y="1457" width="222" height="23"/>
301+
<rect key="frame" x="46" y="1545" width="222" height="23"/>
301302
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
302303
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="10"/>
303304
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
304305
<nil key="highlightedColor"/>
305306
</label>
306307
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Copyright (c) 2014 MineS Chan" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="020-5M-uph">
307-
<rect key="frame" x="49" y="1473" width="222" height="23"/>
308+
<rect key="frame" x="46" y="1561" width="222" height="23"/>
308309
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
309310
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="10"/>
310311
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
311312
<nil key="highlightedColor"/>
312313
</label>
313314
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" MIT licensed." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="71G-Yy-301">
314-
<rect key="frame" x="49" y="1488" width="222" height="23"/>
315+
<rect key="frame" x="46" y="1576" width="222" height="23"/>
315316
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
316317
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="10"/>
317318
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
@@ -377,11 +378,25 @@
377378
<action selector="toggleStopwatchBeyond24Hours:" destination="-1" eventType="touchUpInside" id="xdD-GB-axE"/>
378379
</connections>
379380
</button>
381+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="timer here in text" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="TBf-ji-c4u">
382+
<rect key="frame" x="31" y="1486" width="256" height="51"/>
383+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
384+
<fontDescription key="fontDescription" name="HelveticaNeue-UltraLight" family="Helvetica Neue" pointSize="35"/>
385+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
386+
<nil key="highlightedColor"/>
387+
</label>
388+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="13. Countdown timer in text" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="7Pq-Ej-cSP">
389+
<rect key="frame" x="20" y="1457" width="289" height="21"/>
390+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
391+
<fontDescription key="fontDescription" name="HelveticaNeue-LightItalic" family="Helvetica Neue" pointSize="17"/>
392+
<color key="textColor" red="0.89407286350000004" green="0.48468174000000003" blue="0.0034123939199999999" alpha="1" colorSpace="calibratedRGB"/>
393+
<nil key="highlightedColor"/>
394+
</label>
380395
</subviews>
381396
<color key="backgroundColor" red="0.99348294005102045" green="0.99348294005102045" blue="0.99348294005102045" alpha="1" colorSpace="calibratedRGB"/>
382397
<nil key="simulatedStatusBarMetrics"/>
383398
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
384-
<point key="canvasLocation" x="828" y="790.5"/>
399+
<point key="canvasLocation" x="828" y="834.5"/>
385400
</scrollView>
386401
</objects>
387402
<simulatedMetricsContainer key="defaultSimulatedMetrics">

MZTimerLabelDemo/MZTimerLabelDemo/MZTLViewController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
MZTimerLabel *timerExample10;
2121
MZTimerLabel *timerExample11;
2222
MZTimerLabel *timerExample12;
23+
MZTimerLabel *timerExample13;
2324
}
2425

2526
/*Controls for Example 1*/
@@ -82,4 +83,7 @@
8283
- (IBAction)startStopwatchBeyond23Hours:(id)sender;
8384
- (IBAction)toggleStopwatchBeyond24Hours:(id)sender;
8485

86+
/*Controls and Methods for Example 13*/
87+
@property (weak, nonatomic) IBOutlet UILabel *lblTimerExample13;
88+
8589
@end

MZTimerLabelDemo/MZTimerLabelDemo/MZTLViewController.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ - (void)viewDidLoad
143143
timerExample12 = [[MZTimerLabel alloc] initWithLabel:_lblTimerExample12 andTimerType:MZTimerLabelTypeStopWatch];
144144
[timerExample12 setStopWatchTime:86395];
145145
[timerExample12 setShouldCountBeyondHHLimit:YES];
146+
147+
/*******************************************
148+
* ------Example 13-----
149+
* Countdown timer in text in custom range
150+
********************************************/
151+
152+
timerExample13 = [[MZTimerLabel alloc] initWithLabel:_lblTimerExample13 andTimerType:MZTimerLabelTypeTimer];
153+
[timerExample13 setCountDownTime:999];
154+
NSString* text = @"timer here in text";
155+
NSRange r = [text rangeOfString:@"here"];
156+
timerExample13.text = text;
157+
timerExample13.textRange = r;
158+
timerExample13.timeFormat = @"ss";
159+
timerExample13.resetTimerAfterFinish = YES;
160+
[timerExample13 start];
146161

147162
}
148163

@@ -328,5 +343,4 @@ - (IBAction)toggleStopwatchBeyond24Hours:(id)sender {
328343
[timerExample12 setShouldCountBeyondHHLimit:!timerExample12.shouldCountBeyondHHLimit];
329344
}
330345

331-
332346
@end

0 commit comments

Comments
 (0)