Skip to content

Commit e7f625a

Browse files
committed
Add label with arbitrary latex.
1 parent e11aaba commit e7f625a

File tree

4 files changed

+74
-28
lines changed

4 files changed

+74
-28
lines changed

iosMath.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
1CC48E8D526E9958A3D45383 /* libPods-iosMathTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 33459E3F7CC9ECC36CCA7414 /* libPods-iosMathTests.a */; };
1011
490465BF1D23DA8400F82033 /* MTTypesetterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 490465BE1D23DA8400F82033 /* MTTypesetterTest.m */; };
1112
492EED0817DAEDD200939107 /* MTFontManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 492EECFA17DAED9000939107 /* MTFontManager.m */; };
1213
492EED0917DAEDD200939107 /* MTFontMathTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 492EECF817DAED9000939107 /* MTFontMathTable.m */; };
@@ -51,8 +52,7 @@
5152
49DEC8B81CF77B00000053CD /* MTMathListIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DEC8B61CF77B00000053CD /* MTMathListIndex.h */; };
5253
49EEFD7C1D19B664002D15C4 /* MTTypesetter.h in Headers */ = {isa = PBXBuildFile; fileRef = 49EEFD7A1D19B664002D15C4 /* MTTypesetter.h */; settings = {ATTRIBUTES = (Private, ); }; };
5354
49EEFD7D1D19B664002D15C4 /* MTTypesetter.m in Sources */ = {isa = PBXBuildFile; fileRef = 49EEFD7B1D19B664002D15C4 /* MTTypesetter.m */; };
54-
66B91F54A155071228C33E27 /* libPods-iosMathExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B7305B3D5272E07D296E1146 /* libPods-iosMathExample.a */; };
55-
A4AF82224BB9060CC51567E8 /* libPods-iosMathTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 847963E8DF103FF2BAABFCD8 /* libPods-iosMathTests.a */; };
55+
5CA7D6C1A46D34A00133B0C2 /* libPods-iosMathExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 11BDFD1AB91580A33D83C75E /* libPods-iosMathExample.a */; };
5656
D94FE3531B90DD29002D11E2 /* MTMathUILabel.h in Headers */ = {isa = PBXBuildFile; fileRef = 492EECF417DAED9000939107 /* MTMathUILabel.h */; settings = {ATTRIBUTES = (Public, ); }; };
5757
D94FE3541B90DE46002D11E2 /* MTMathListDisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = 492EECF317DAED9000939107 /* MTMathListDisplay.h */; settings = {ATTRIBUTES = (Public, ); }; };
5858
D94FE3551B90DE5B002D11E2 /* MTMathList.h in Headers */ = {isa = PBXBuildFile; fileRef = 492EED0217DAEDB500939107 /* MTMathList.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -72,6 +72,8 @@
7272
/* End PBXCopyFilesBuildPhase section */
7373

7474
/* Begin PBXFileReference section */
75+
11BDFD1AB91580A33D83C75E /* libPods-iosMathExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iosMathExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
76+
33459E3F7CC9ECC36CCA7414 /* libPods-iosMathTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iosMathTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
7577
490465BE1D23DA8400F82033 /* MTTypesetterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTTypesetterTest.m; sourceTree = "<group>"; };
7678
492EECF317DAED9000939107 /* MTMathListDisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTMathListDisplay.h; sourceTree = "<group>"; };
7779
492EECF417DAED9000939107 /* MTMathUILabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTMathUILabel.h; sourceTree = "<group>"; };
@@ -130,10 +132,8 @@
130132
49EEFD7A1D19B664002D15C4 /* MTTypesetter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTTypesetter.h; sourceTree = "<group>"; };
131133
49EEFD7B1D19B664002D15C4 /* MTTypesetter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTTypesetter.m; sourceTree = "<group>"; };
132134
49EEFD7E1D19B94C002D15C4 /* MTMathListDisplayInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTMathListDisplayInternal.h; sourceTree = "<group>"; };
133-
847963E8DF103FF2BAABFCD8 /* libPods-iosMathTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iosMathTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
134135
964660A84E6FEDD150C994C8 /* Pods-iosMathTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosMathTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-iosMathTests/Pods-iosMathTests.release.xcconfig"; sourceTree = "<group>"; };
135136
B16B9A63054AE3FFB5C36F6B /* Pods-iosMathExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosMathExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-iosMathExample/Pods-iosMathExample.release.xcconfig"; sourceTree = "<group>"; };
136-
B7305B3D5272E07D296E1146 /* libPods-iosMathExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iosMathExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
137137
BB4250423755E0D3CD2BA614 /* Pods-iosMathTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosMathTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iosMathTests/Pods-iosMathTests.debug.xcconfig"; sourceTree = "<group>"; };
138138
D93290960585498BBAEE4535 /* Pods-iosMathExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosMathExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iosMathExample/Pods-iosMathExample.debug.xcconfig"; sourceTree = "<group>"; };
139139
D94FE3501B90DCA5002D11E2 /* IosMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IosMath.h; sourceTree = "<group>"; };
@@ -160,7 +160,7 @@
160160
49965F0017CBBA2700A555C5 /* UIKit.framework in Frameworks */,
161161
49965F0217CBBA2700A555C5 /* Foundation.framework in Frameworks */,
162162
49965F0417CBBA2700A555C5 /* CoreGraphics.framework in Frameworks */,
163-
66B91F54A155071228C33E27 /* libPods-iosMathExample.a in Frameworks */,
163+
5CA7D6C1A46D34A00133B0C2 /* libPods-iosMathExample.a in Frameworks */,
164164
);
165165
runOnlyForDeploymentPostprocessing = 0;
166166
};
@@ -170,7 +170,7 @@
170170
files = (
171171
49965F1F17CBBA2700A555C5 /* UIKit.framework in Frameworks */,
172172
49965F2017CBBA2700A555C5 /* Foundation.framework in Frameworks */,
173-
A4AF82224BB9060CC51567E8 /* libPods-iosMathTests.a in Frameworks */,
173+
1CC48E8D526E9958A3D45383 /* libPods-iosMathTests.a in Frameworks */,
174174
);
175175
runOnlyForDeploymentPostprocessing = 0;
176176
};
@@ -235,8 +235,8 @@
235235
49965F0117CBBA2700A555C5 /* Foundation.framework */,
236236
49965F0317CBBA2700A555C5 /* CoreGraphics.framework */,
237237
49A27B0218EBF5B30030B7EF /* CoreFoundation.framework */,
238-
B7305B3D5272E07D296E1146 /* libPods-iosMathExample.a */,
239-
847963E8DF103FF2BAABFCD8 /* libPods-iosMathTests.a */,
238+
11BDFD1AB91580A33D83C75E /* libPods-iosMathExample.a */,
239+
33459E3F7CC9ECC36CCA7414 /* libPods-iosMathTests.a */,
240240
);
241241
name = Frameworks;
242242
sourceTree = "<group>";

iosMath.xcodeproj/xcshareddata/xcschemes/iosMath.xcscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
buildForAnalyzing = "YES">
2929
<BuildableReference
3030
BuildableIdentifier = "primary"
31-
BlueprintIdentifier = "2B12F5A5ED62926BB4BAC15C"
31+
BlueprintIdentifier = "43219EE72093CB9A13AF736B"
3232
BuildableName = "libPods-iosMathExample.a"
3333
BlueprintName = "Pods-iosMathExample"
3434
ReferencedContainer = "container:Pods/Pods.xcodeproj">
@@ -42,7 +42,7 @@
4242
buildForAnalyzing = "YES">
4343
<BuildableReference
4444
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "3473C13BC0F9D82468C474F4"
45+
BlueprintIdentifier = "1312454232A5AD3173CEB380"
4646
BuildableName = "libPods-iosMathTests.a"
4747
BlueprintName = "Pods-iosMathTests"
4848
ReferencedContainer = "container:Pods/Pods.xcodeproj">

iosMathExample/View.xib

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<connections>
99
<outlet property="colorField" destination="1HJ-UO-PhD" id="Fc8-fs-Eyn"/>
1010
<outlet property="fontField" destination="1Dd-7L-RPK" id="zcS-qn-nUV"/>
11+
<outlet property="latexField" destination="j6C-0z-6Qw" id="9Z1-DX-MjR"/>
12+
<outlet property="mathLabel" destination="jao-lN-IEn" id="egL-zv-PTj"/>
1113
<outlet property="scrollView" destination="wDa-bp-SwP" id="6da-gg-PFq"/>
1214
<outlet property="view" destination="iN0-l3-epB" id="eWW-zj-uRT"/>
1315
</connections>
@@ -17,20 +19,13 @@
1719
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
1820
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1921
<subviews>
20-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IrN-GL-LDP" userLabel="Render">
21-
<rect key="frame" x="0.0" y="20" width="320" height="0.0"/>
22-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
23-
<constraints>
24-
<constraint firstAttribute="height" id="9eh-ts-PLz"/>
25-
</constraints>
26-
</view>
2722
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TgX-F7-Ft9" userLabel="Fonts">
2823
<rect key="frame" x="0.0" y="20" width="320" height="55"/>
2924
<subviews>
3025
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Font" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jX6-20-7Ej" userLabel="Font">
3126
<rect key="frame" x="20" y="17" width="35" height="21"/>
3227
<fontDescription key="fontDescription" type="system" pointSize="17"/>
33-
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
28+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
3429
<nil key="highlightedColor"/>
3530
</label>
3631
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Select Font" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="1Dd-7L-RPK">
@@ -77,30 +72,64 @@
7772
<constraint firstItem="1HJ-UO-PhD" firstAttribute="height" secondItem="1Dd-7L-RPK" secondAttribute="height" id="xuW-a9-O1y"/>
7873
</constraints>
7974
</view>
75+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IrN-GL-LDP" userLabel="Render">
76+
<rect key="frame" x="0.0" y="75" width="320" height="135"/>
77+
<subviews>
78+
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter Latex" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="j6C-0z-6Qw">
79+
<rect key="frame" x="20" y="10" width="280" height="35"/>
80+
<constraints>
81+
<constraint firstAttribute="height" constant="35" id="dAK-7d-pE1"/>
82+
</constraints>
83+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
84+
<textInputTraits key="textInputTraits"/>
85+
</textField>
86+
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jao-lN-IEn" customClass="MTMathUILabel">
87+
<rect key="frame" x="10" y="65" width="300" height="60"/>
88+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
89+
<constraints>
90+
<constraint firstAttribute="height" constant="60" id="PuX-Tv-Qad"/>
91+
</constraints>
92+
</view>
93+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QuP-Xq-lLY" userLabel="Line">
94+
<rect key="frame" x="0.0" y="134" width="320" height="1"/>
95+
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
96+
<constraints>
97+
<constraint firstAttribute="height" constant="1" id="aT7-4u-UkV"/>
98+
</constraints>
99+
</view>
100+
</subviews>
101+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
102+
<constraints>
103+
<constraint firstItem="jao-lN-IEn" firstAttribute="leading" secondItem="IrN-GL-LDP" secondAttribute="leading" constant="10" id="Idv-9Z-Ezx"/>
104+
<constraint firstItem="j6C-0z-6Qw" firstAttribute="leading" secondItem="IrN-GL-LDP" secondAttribute="leading" constant="20" id="L9y-4K-jzh"/>
105+
<constraint firstAttribute="trailing" secondItem="jao-lN-IEn" secondAttribute="trailing" constant="10" id="TIp-bA-ooh"/>
106+
<constraint firstItem="QuP-Xq-lLY" firstAttribute="leading" secondItem="IrN-GL-LDP" secondAttribute="leading" id="a2Q-Qk-xO8"/>
107+
<constraint firstAttribute="bottom" secondItem="jao-lN-IEn" secondAttribute="bottom" constant="10" id="fek-2u-ET0"/>
108+
<constraint firstItem="jao-lN-IEn" firstAttribute="top" secondItem="j6C-0z-6Qw" secondAttribute="bottom" constant="20" id="g8G-QF-JEO"/>
109+
<constraint firstAttribute="bottom" secondItem="QuP-Xq-lLY" secondAttribute="bottom" id="lLf-B5-26y"/>
110+
<constraint firstAttribute="trailing" secondItem="QuP-Xq-lLY" secondAttribute="trailing" id="n6S-PX-TUJ"/>
111+
<constraint firstAttribute="trailing" secondItem="j6C-0z-6Qw" secondAttribute="trailing" constant="20" id="q73-wn-i09"/>
112+
<constraint firstItem="j6C-0z-6Qw" firstAttribute="top" secondItem="IrN-GL-LDP" secondAttribute="top" constant="10" id="rsO-z0-LyN"/>
113+
</constraints>
114+
</view>
80115
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wDa-bp-SwP">
81-
<rect key="frame" x="0.0" y="75" width="320" height="493"/>
116+
<rect key="frame" x="0.0" y="210" width="320" height="358"/>
82117
</scrollView>
83118
</subviews>
84119
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
85120
<constraints>
86121
<constraint firstItem="IrN-GL-LDP" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="BtD-OF-svA"/>
87122
<constraint firstAttribute="trailing" secondItem="wDa-bp-SwP" secondAttribute="trailing" id="C0m-0B-cv0"/>
88123
<constraint firstItem="wDa-bp-SwP" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="CIa-NN-LQQ"/>
89-
<constraint firstItem="wDa-bp-SwP" firstAttribute="top" secondItem="TgX-F7-Ft9" secondAttribute="bottom" id="OMI-Pf-JsZ"/>
90-
<constraint firstItem="IrN-GL-LDP" firstAttribute="bottom" secondItem="TgX-F7-Ft9" secondAttribute="top" id="QqM-Wx-L9v"/>
91-
<constraint firstItem="wDa-bp-SwP" firstAttribute="top" secondItem="TgX-F7-Ft9" secondAttribute="bottom" id="TJf-8x-jrL"/>
124+
<constraint firstItem="TgX-F7-Ft9" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="20" id="Fis-nP-0AJ"/>
125+
<constraint firstItem="wDa-bp-SwP" firstAttribute="top" secondItem="IrN-GL-LDP" secondAttribute="bottom" id="UhX-jz-ncx"/>
92126
<constraint firstAttribute="trailing" secondItem="TgX-F7-Ft9" secondAttribute="trailing" id="mVc-5a-nR7"/>
93127
<constraint firstAttribute="bottom" secondItem="wDa-bp-SwP" secondAttribute="bottom" id="oV2-Lm-VPv"/>
94-
<constraint firstItem="IrN-GL-LDP" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="20" id="pUc-Fn-uDN"/>
128+
<constraint firstItem="TgX-F7-Ft9" firstAttribute="bottom" secondItem="IrN-GL-LDP" secondAttribute="top" id="tZ2-Dz-qHR"/>
95129
<constraint firstItem="TgX-F7-Ft9" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="wNT-dG-ZpS"/>
96130
<constraint firstAttribute="trailing" secondItem="IrN-GL-LDP" secondAttribute="trailing" id="zGC-B7-bov"/>
97131
</constraints>
98132
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
99-
<variation key="default">
100-
<mask key="constraints">
101-
<exclude reference="TJf-8x-jrL"/>
102-
</mask>
103-
</variation>
104133
<point key="canvasLocation" x="340" y="122"/>
105134
</view>
106135
</objects>

iosMathExample/example/ViewController.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ @interface ViewController () <UITextFieldDelegate>
3535
@property (nonatomic) FontPickerDelegate* pickerDelegate;
3636
@property (weak, nonatomic) IBOutlet UITextField *colorField;
3737
@property (nonatomic) ColorPickerDelegate* colorPickerDelegate;
38+
@property (weak, nonatomic) IBOutlet MTMathUILabel *mathLabel;
39+
@property (weak, nonatomic) IBOutlet UITextField *latexField;
3840

3941
@end
4042

@@ -73,6 +75,8 @@ - (void)viewDidLoad
7375
self.colorField.inputView = picker;
7476
self.colorField.delegate = self;
7577

78+
self.latexField.delegate = self;
79+
7680
UIView* contentView = [[UIView alloc] init];
7781
[self addFullSizeView:contentView to:self.scrollView];
7882
// set the size of the content view
@@ -430,6 +434,19 @@ - (void) changeColor:(UIColor*) color
430434

431435
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
432436
{
437+
if (textField == self.latexField) {
438+
return YES;
439+
}
440+
return NO;
441+
}
442+
443+
- (BOOL)textFieldShouldReturn:(UITextField *)textField
444+
{
445+
if (textField == self.latexField) {
446+
[textField resignFirstResponder];
447+
self.mathLabel.latex = self.latexField.text;
448+
return YES;
449+
}
433450
return NO;
434451
}
435452

0 commit comments

Comments
 (0)