Fixes #64
This commit is contained in:
parent
f1ead65825
commit
77b51a9592
|
@ -22,7 +22,7 @@ A struct defining the styles that can be applied to the parsed Markdown. The `fo
|
|||
If that is not set, then the system default will be used.
|
||||
*/
|
||||
@objc open class BasicStyles : NSObject, FontProperties {
|
||||
public var fontName : String? = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body).fontName
|
||||
public var fontName : String?
|
||||
public var color = UIColor.black
|
||||
public var fontSize : CGFloat = 0.0
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ enum LineType : Int {
|
|||
case h1, h2, h3, h4, h5, h6, body
|
||||
}
|
||||
|
||||
|
||||
enum LineStyle : Int {
|
||||
case none
|
||||
case italic
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
@ -23,31 +20,55 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qZP-CU-74n">
|
||||
<rect key="frame" x="16" y="20" width="343" height="601"/>
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="583"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<attributedString key="attributedText"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
<dataDetectorType key="dataDetectorTypes" link="YES"/>
|
||||
</textView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JK2-Lo-xRa">
|
||||
<rect key="frame" x="164" y="629" width="47" height="30"/>
|
||||
<state key="normal" title="Reload"/>
|
||||
<connections>
|
||||
<action selector="reloadText:" destination="BYZ-38-t0r" eventType="touchUpInside" id="fGe-1g-NTo"/>
|
||||
</connections>
|
||||
</button>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="je8-G1-qej">
|
||||
<rect key="frame" x="24" y="591" width="327" height="68"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="EOv-1r-ixy">
|
||||
<rect key="frame" x="0.0" y="0.0" width="327" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="XzJ-SY-mRx">
|
||||
<rect key="frame" x="0.0" y="34" width="327" height="34"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ksq-jO-8Gt">
|
||||
<rect key="frame" x="0.0" y="0.0" width="163.5" height="34"/>
|
||||
<state key="normal" title="Reload File"/>
|
||||
<connections>
|
||||
<action selector="reloadText:" destination="BYZ-38-t0r" eventType="touchUpInside" id="dg3-xi-352"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" horizontalCompressionResistancePriority="752" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JK2-Lo-xRa">
|
||||
<rect key="frame" x="163.5" y="0.0" width="163.5" height="34"/>
|
||||
<state key="normal" title="Process Text"/>
|
||||
<connections>
|
||||
<action selector="processText:" destination="BYZ-38-t0r" eventType="touchUpInside" id="e9I-rJ-ifc"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</subviews>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="qZP-CU-74n" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="1yU-8N-26a"/>
|
||||
<constraint firstItem="JK2-Lo-xRa" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="3Zx-lw-7hH"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="qZP-CU-74n" secondAttribute="trailing" id="F5p-iG-zTB"/>
|
||||
<constraint firstItem="JK2-Lo-xRa" firstAttribute="top" secondItem="qZP-CU-74n" secondAttribute="bottom" constant="8" id="Rod-d1-6Yb"/>
|
||||
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="JK2-Lo-xRa" secondAttribute="bottom" constant="8" id="Yc0-Xe-YPV"/>
|
||||
<constraint firstAttribute="trailingMargin" secondItem="je8-G1-qej" secondAttribute="trailing" constant="8" id="JKP-2n-p24"/>
|
||||
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="je8-G1-qej" secondAttribute="bottom" constant="8" id="cvL-k7-iKp"/>
|
||||
<constraint firstItem="je8-G1-qej" firstAttribute="top" secondItem="qZP-CU-74n" secondAttribute="bottom" constant="8" id="gnq-BF-hFJ"/>
|
||||
<constraint firstItem="je8-G1-qej" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" constant="8" id="kJ0-Hf-RwN"/>
|
||||
<constraint firstItem="qZP-CU-74n" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="srf-u0-j0n"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="textField" destination="EOv-1r-ixy" id="k2p-vH-CR0"/>
|
||||
<outlet property="textView" destination="qZP-CU-74n" id="VO1-kx-Lpd"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
|
|
|
@ -11,6 +11,8 @@ import SwiftyMarkdown
|
|||
|
||||
class ViewController: UIViewController {
|
||||
|
||||
|
||||
@IBOutlet weak var textField : UITextField!
|
||||
@IBOutlet weak var textView : UITextView!
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
@ -18,18 +20,21 @@ class ViewController: UIViewController {
|
|||
|
||||
// This is to help debugging.
|
||||
reloadText(nil)
|
||||
|
||||
self.textField.text = "Yo I'm a *single* line **string**. How do I look?"
|
||||
}
|
||||
|
||||
@IBAction func processText( _ sender : UIButton? ) {
|
||||
guard let existentText = self.textField.text else {
|
||||
return
|
||||
}
|
||||
self.textView.attributedText = SwiftyMarkdown(string: existentText).attributedString()
|
||||
}
|
||||
|
||||
@IBAction func reloadText( _ sender : UIButton? ) {
|
||||
|
||||
self.textView.dataDetectorTypes = UIDataDetectorTypes.all
|
||||
|
||||
if self.textView.text != "" {
|
||||
self.textView.attributedText = SwiftyMarkdown(string: "Yo I'm a *single* line **string**. How do I look?").attributedString()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if let url = Bundle.main.url(forResource: "example", withExtension: "md"), let md = SwiftyMarkdown(url: url) {
|
||||
md.h2.fontName = "AvenirNextCondensed-Bold"
|
||||
md.h2.color = UIColor.red
|
||||
|
|
Loading…
Reference in New Issue