Skip to content

Commit 6f6b357

Browse files
committed
more sensible geometry
1 parent ff496c7 commit 6f6b357

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

bk2ch10p537exclusionPath2/ch23p813textKitShapes/Base.lproj/Main.storyboard

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6185.11" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6190.4"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
55
</dependencies>
66
<scenes>
77
<!--View Controller-->
@@ -17,7 +17,7 @@
1717
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1818
<subviews>
1919
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZiI-oe-FbW">
20-
<rect key="frame" x="37" y="20" width="246" height="257"/>
20+
<rect key="frame" x="0.0" y="20" width="320" height="257"/>
2121
<color key="backgroundColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
2222
<constraints>
2323
<constraint firstAttribute="height" constant="257" id="2hD-0u-bgc"/>
@@ -30,8 +30,8 @@
3030
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
3131
<constraints>
3232
<constraint firstItem="ZiI-oe-FbW" firstAttribute="top" secondItem="qOu-jN-vXC" secondAttribute="bottom" id="IKo-pU-iUX"/>
33-
<constraint firstAttribute="trailing" secondItem="ZiI-oe-FbW" secondAttribute="trailing" constant="37" id="RFF-eE-Idp"/>
34-
<constraint firstItem="ZiI-oe-FbW" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" constant="37" id="SNg-MY-Ers"/>
33+
<constraint firstAttribute="trailing" secondItem="ZiI-oe-FbW" secondAttribute="trailing" id="RFF-eE-Idp"/>
34+
<constraint firstItem="ZiI-oe-FbW" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" id="SNg-MY-Ers"/>
3535
</constraints>
3636
</view>
3737
<connections>
@@ -45,9 +45,6 @@
4545
<simulatedMetricsContainer key="defaultSimulatedMetrics">
4646
<simulatedStatusBarMetrics key="statusBar"/>
4747
<simulatedOrientationMetrics key="orientation"/>
48-
<simulatedScreenMetrics key="destination" type="retina4">
49-
<size key="portraitSize" width="320" height="568"/>
50-
<size key="landscapeSize" width="568" height="320"/>
51-
</simulatedScreenMetrics>
48+
<simulatedScreenMetrics key="destination" type="retina4"/>
5249
</simulatedMetricsContainer>
5350
</document>

bk2ch10p537exclusionPath2/ch23p813textKitShapes/MyTextContainer.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ class MyTextContainer : NSTextContainer {
1919
}
2020
*/
2121

22-
let r = self.size.width / 2.0
22+
let r = self.size.height / 2.0
2323
// convert initial y so that circle is centered at origin
2424
let y = r - result.origin.y
2525
let theta = asin(y/r)
2626
let x = r * cos(theta)
2727
// convert resulting x from circle centered at origin
28-
result.origin.x = r-x
28+
let offset = self.size.width / 2.0 - r
29+
result.origin.x = r-x+offset
2930
result.size.width = 2*x
3031

3132

0 commit comments

Comments
 (0)