mirror of
https://github.com/samsonjs/UIKitCatalog.git
synced 2026-03-25 08:55:51 +00:00
Upgraded for Xcode 12.2
This commit is contained in:
parent
35310e33ea
commit
99662c6c00
33 changed files with 678 additions and 257 deletions
36
README.md
36
README.md
|
|
@ -1,10 +1,10 @@
|
|||
# UIKit Catalog: Creating and Customizing Views and Controls
|
||||
|
||||
Customize your app's user interface with views and controls in UIKit.
|
||||
Customize your app's user interface with views and controls.
|
||||
|
||||
## Overview
|
||||
|
||||
This sample guides you through several types of customizations that you can make in your iOS app. The sample uses a split view controller architecture for navigating UIKit views and controls. The primary view controller (`MasterViewController`) shows the available views and controls. Selecting one shows the secondary view controller associated with it.
|
||||
This sample guides you through several types of customizations you can make in your iOS app. The sample uses a split-view controller architecture for navigating UIKit views and controls. The primary view controller (`MasterViewController`) shows the available views and controls. When you select one, `MasterViewController` shows the secondary view controller associated with it.
|
||||
|
||||
The name of each secondary view controller reflects its *target item*. For example, the `AlertControllerViewController` class shows how to use a `UIAlertController` object. The only exceptions to this rule are `UISearchBar` and `UIToolbar`; the sample demonstrates these APIs in multiple view controllers to explain how their controls function and how to customize them. To demonstrate how to manage the complexity of your storyboards, the app hosts all view controllers in a separate storyboard and loaded when needed.
|
||||
|
||||
|
|
@ -16,6 +16,7 @@ This sample demonstrates the following views and controls (several of which are
|
|||
* [`UIDatePicker`](https://developer.apple.com/documentation/uikit/uidatepicker)
|
||||
* [`UIPickerView`](https://developer.apple.com/documentation/uikit/uipickerview)
|
||||
* [`UIColorPickerViewController`](https://developer.apple.com/documentation/uikit/uicolorpickerviewcontroller)
|
||||
* [`UIColorWell`](https://developer.apple.com/documentation/uikit/uicolorwell)
|
||||
* [`UIFontPickerViewController`](https://developer.apple.com/documentation/uikit/uifontpickerviewcontroller)
|
||||
* [`UIImagePickerViewController`](https://developer.apple.com/documentation/uikit/uiimagepickercontroller)
|
||||
* [`UIImageView`](https://developer.apple.com/documentation/uikit/uiimageview)
|
||||
|
|
@ -28,13 +29,14 @@ This sample demonstrates the following views and controls (several of which are
|
|||
* [`UIStepper`](https://developer.apple.com/documentation/uikit/uistepper)
|
||||
* [`UISwitch`](https://developer.apple.com/documentation/uikit/uiswitch)
|
||||
* [`UITextField`](https://developer.apple.com/documentation/uikit/uitextfield)
|
||||
* [`UITextFormattingCoordinator`](https://developer.apple.com/documentation/uikit/uitextformattingcoordinator)
|
||||
* [`UITextView`](https://developer.apple.com/documentation/uikit/uitextview)
|
||||
* [`UIToolbar`](https://developer.apple.com/documentation/uikit/uitoolbar)
|
||||
* [`WKWebView`](https://developer.apple.com/documentation/webkit/wkwebview)
|
||||
|
||||
## Add Accessibility Support to Your Views
|
||||
|
||||
VoiceOver and other system accessibility technologies use the information provided by your views and controls to help all users navigate your content. UIKit views include default accessibility support, but you can improve the user experience by providing custom accessibility information.
|
||||
VoiceOver and other system accessibility technologies use the information provided by views and controls to help all users navigate content. UIKit views include default accessibility support. Improve user experience by providing custom accessibility information.
|
||||
|
||||
In this UIKitCatalog sample, several view controllers configure the `accessibilityType` and `accessibilityLabel` properties of their associated view. Picker view columns don't have labels, so the picker view asks its delegate for the corresponding accessibility information:
|
||||
|
||||
|
|
@ -56,14 +58,14 @@ func pickerView(_ pickerView: UIPickerView, accessibilityLabelForComponent compo
|
|||
|
||||
## Display a Custom Alert
|
||||
|
||||
`AlertControllerViewController` demonstrates several techniques for displaying modal alerts and action sheets from your interface. The configuration process is similar for all alerts:
|
||||
`AlertControllerViewController` demonstrates several techniques for displaying modal alerts and action sheets from an interface. The configuration process is similar for all alerts:
|
||||
|
||||
1. Determine the message you want to display in the alert.
|
||||
2. Create and configure a `UIAlertController` object.
|
||||
3. Add handlers for actions that the user may take.
|
||||
3. Add handlers for actions the user may take.
|
||||
4. Present the alert controller.
|
||||
|
||||
The `showSimpleAlert` function uses the `NSLocalizedString` function to retrieve the alert messages in the user’s preferred language. The `showSimpleAlert` function uses those strings to create and configure the `UIAlertController` object. Although the button in the alert has the title OK, the sample uses a cancel action to ensure that the alert controller applies the proper styling to the button:
|
||||
The `showSimpleAlert` function uses the `NSLocalizedString` function to retrieve the alert messages in the user’s preferred language. The `showSimpleAlert` function uses those strings to create and configure the `UIAlertController` object. Although the button in the alert has the title OK, the sample uses a cancel action to ensure the alert controller applies the proper styling to the button:
|
||||
|
||||
``` swift
|
||||
func showSimpleAlert() {
|
||||
|
|
@ -87,7 +89,7 @@ func showSimpleAlert() {
|
|||
|
||||
## Customize the Appearance of Sliders
|
||||
|
||||
This sample demonstrates different ways to display a `UISlider`, a control used to select a single value from a continuous range of values. You customize the appearance of a slider by assigning stretchable images for left-side tracking, right-side tracking, and the thumb. In this example, the track image is stretchable and is one pixel wide. Make the track images wider to provide rounded corners, but be sure to set these images' `capInsets` property to allow for the corners.
|
||||
This sample demonstrates different ways to display a `UISlider`, a control you use to select a single value from a continuous range of values. Customize the appearance of a slider by assigning stretchable images for left-side tracking, right-side tracking, and the thumb. In this example, the track image is stretchable and is one pixel wide. Make the track images wider to provide rounded corners, but be sure to set these images' `capInsets` property to allow for the corners.
|
||||
|
||||
The `configureCustomSlider` function sets up a custom slider:
|
||||
|
||||
|
|
@ -115,9 +117,9 @@ func configureCustomSlider() {
|
|||
}
|
||||
```
|
||||
|
||||
## Add a Search Bar to Your Interface
|
||||
## Add a Search Bar to an Interface
|
||||
|
||||
Use a `UISearchBar` for receiving search-related information from the user. There are various ways to customize the look of the search bar:
|
||||
Use a `UISearchBar` to receive search-related information from the user. There are various ways to customize the look of the search bar:
|
||||
|
||||
* Add a cancel button.
|
||||
* Add a bookmark button.
|
||||
|
|
@ -147,7 +149,7 @@ func configureSearchBar() {
|
|||
|
||||
## Customize the Appearance of Toolbars
|
||||
|
||||
This sample shows how to customize a `UIToolbar`, a specialized view that displays one or more buttons along the bottom edge of your interface. Customize a toolbar by determining its bar style (black or default), translucency, tint color, and background color.
|
||||
This sample shows how to customize a `UIToolbar`, a specialized view that displays one or more buttons along the bottom edge of an interface. Customize a toolbar by determining its bar style (black or default), translucency, tint color, and background color.
|
||||
|
||||
The following `viewDidLoad` function in `CustomToolbarViewController` sets up a tinted tool bar:
|
||||
|
||||
|
|
@ -191,7 +193,7 @@ override func viewDidLoad() {
|
|||
|
||||
## Add a Page Control Interface
|
||||
|
||||
Use a `UIPageControl` to structure your app's user interface. A page control is a specialized control that displays a horizontal series of dots, each of which corresponds to a page in the app’s document or other data-model entity. You customize a page control by setting its tint color for all the page indicator dots, and for the current page indicator dot.
|
||||
Use a `UIPageControl` to structure an app's user interface. A page control is a specialized control that displays a horizontal series of dots, each of which corresponds to a page in the app’s document or other data-model entity. Customize a page control by setting its tint color for all the page-indicator dots, and for the current page-indicator dot.
|
||||
|
||||
The `configurePageControl` function sets up a customized page control:
|
||||
|
||||
|
|
@ -210,7 +212,7 @@ func configurePageControl() {
|
|||
|
||||
## Add Menus to Your Controls
|
||||
|
||||
You can attach menus to controls like `UIButton` and `UIBarButtonItem`. Create menus with the [`UIAction`](https://developer.apple.com/documentation/uikit/uiaction) class, and attach a menu to each control by setting the [`UIMenu`](https://developer.apple.com/documentation/uikit/uimenu) property.
|
||||
Attach menus to controls like `UIButton` and `UIBarButtonItem`. Create menus with the [`UIAction`](https://developer.apple.com/documentation/uikit/uiaction) class, and attach a menu to each control by setting the [`UIMenu`](https://developer.apple.com/documentation/uikit/uimenu) property.
|
||||
|
||||
Attach a menu to a `UIButton` as shown here:
|
||||
|
||||
|
|
@ -239,4 +241,14 @@ var customTitleBarButtonItem: UIBarButtonItem {
|
|||
}
|
||||
```
|
||||
|
||||
## Support Mac Catalyst
|
||||
|
||||
This sample app is built with Mac Catalyst, which means the sample runs on both iPad and Mac. This is achieved by selecting the Mac checkbox in Project Settings. For more about how Mac Catalyst works see [Mac Catalyst](https://developer.apple.com/mac-catalyst/).
|
||||
|
||||
When built for Mac Catalyst, this sample achieves:
|
||||
|
||||
* Interface Optimization for Mac — With Optimize Interface For the Mac project setting turned on, the app has full control of every pixel on the screen, and the app can adopt more controls specific to Mac. Building the sample for Mac Catalyst makes the app take advantage of the system features in macOS. The option Show Designed for iPad Run Destination allows this sample, as an iPad app, to run "as-is" on Apple silicon Macs. This requires macOS 11 and a Mac with Apple silicon.
|
||||
|
||||
* Navigation and title bar hiding — The sample app hides these to make the app appear more like a Mac app. It also changes other behaviors by using traitCollection's `userInterfaceIdiom` or the compilation conditional block that uses the `targetEnvironment():` platform condition.
|
||||
|
||||
* Translucent background — By setting the split view controller's `primaryBackgroundStyle` to `.sidebar`, the primary view controller or side bar shows a blurred desktop behind its view. Setting this property has no effect when running in iOS.
|
||||
|
|
|
|||
|
|
@ -838,9 +838,10 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TARGETED_DEVICE_FAMILY = "1,2,6";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
|
@ -860,9 +861,10 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TARGETED_DEVICE_FAMILY = "1,2,6";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,4 +50,35 @@ class ActivityIndicatorViewController: UITableViewController {
|
|||
tintedSmallActivityIndicatorView.startAnimating()
|
||||
tintedLargeActivityIndicatorView.startAnimating()
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted activitiy indicator for macOS, it does not exist.
|
||||
if section == 1 {
|
||||
return ""
|
||||
} else {
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
||||
override func tableView(_ tableView: UITableView,
|
||||
heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted activity indicator for macOS, it does not exist.
|
||||
if indexPath.section == 1 {
|
||||
return 0
|
||||
} else {
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,8 +115,6 @@ class AlertControllerViewController: UITableViewController {
|
|||
func showTextEntryAlert() {
|
||||
let title = NSLocalizedString("A Short Title is Best", comment: "")
|
||||
let message = NSLocalizedString("A message should be a short, complete sentence.", comment: "")
|
||||
let cancelButtonTitle = NSLocalizedString("Cancel", comment: "")
|
||||
let otherButtonTitle = NSLocalizedString("OK", comment: "")
|
||||
|
||||
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
|
||||
|
|
@ -126,10 +124,12 @@ class AlertControllerViewController: UITableViewController {
|
|||
}
|
||||
|
||||
// Create the actions.
|
||||
let cancelButtonTitle = NSLocalizedString("Cancel", comment: "")
|
||||
let cancelAction = UIAlertAction(title: cancelButtonTitle, style: .cancel) { _ in
|
||||
print("The \"Text Entry\" alert's cancel action occurred.")
|
||||
}
|
||||
|
||||
let otherButtonTitle = NSLocalizedString("OK", comment: "")
|
||||
let otherAction = UIAlertAction(title: otherButtonTitle, style: .default) { _ in
|
||||
print("The \"Text Entry\" alert's other action occurred.")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "increment_disabled_1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "increment_disabled_2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "stepper_increment_disabled_3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3 KiB |
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "increment_highlighted_1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "increment_highlighted_2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "stepper_increment_highlighted_3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3 KiB |
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14800.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Va4-Ge-jQn">
|
||||
<device id="retina4_7" orientation="portrait"/>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17503.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Va4-Ge-jQn">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14758.1"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17502"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="iro-ev-0xV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
|
||||
<sections>
|
||||
<tableViewSection headerTitle="Alert Style" id="JaZ-Ik-3It">
|
||||
<cells>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Simple" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="d6Q-Gp-MaT">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="OK / Cancel" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="d0w-RT-OiQ">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Three Buttons" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="eDM-aO-Nbd">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -78,7 +78,7 @@
|
|||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Text Entry" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="QST-9u-XS2">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Secure Text Entry" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="YMc-Ck-AAm">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Confirm / Cancel" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fSa-fa-39a">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -133,7 +133,7 @@
|
|||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Destructive" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="2dq-Xl-v3s">
|
||||
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="18"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -156,4 +156,9 @@
|
|||
<point key="canvasLocation" x="-3544" y="3368"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<systemColor name="groupTableViewBackgroundColor">
|
||||
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17132" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="gl0-hM-EWg">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17105"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
|
|
@ -89,18 +88,13 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tGF-rn-9B7">
|
||||
<rect key="frame" x="146.5" y="7" width="82" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="30" id="3yG-gd-js4"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="82" id="KcP-fe-RbS"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Button"/>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W4I-NX-srt">
|
||||
<rect key="frame" x="172.5" y="5" width="30" height="34"/>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="centerX" secondItem="tGF-rn-9B7" secondAttribute="centerX" id="Fh5-L2-WPZ"/>
|
||||
<constraint firstAttribute="centerY" secondItem="tGF-rn-9B7" secondAttribute="centerY" id="Puj-LE-SuK"/>
|
||||
<constraint firstItem="W4I-NX-srt" firstAttribute="centerY" secondItem="kI0-Vx-CmV" secondAttribute="centerY" id="3JW-rC-ZTg"/>
|
||||
<constraint firstItem="W4I-NX-srt" firstAttribute="centerX" secondItem="kI0-Vx-CmV" secondAttribute="centerX" id="UlE-gj-Jmh"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
|
|
@ -203,7 +197,7 @@
|
|||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
<outlet property="attributedTextButton" destination="ynp-Un-3Nj" id="GnF-wA-dTM"/>
|
||||
<outlet property="imageButton" destination="tGF-rn-9B7" id="TOD-ga-eqT"/>
|
||||
<outlet property="imageButton" destination="W4I-NX-srt" id="4p1-oE-iSs"/>
|
||||
<outlet property="menuButton" destination="e8l-iZ-Xgp" id="QPX-YE-FIT"/>
|
||||
<outlet property="symbolButton" destination="QwT-La-9Hy" id="sIN-Di-Y0D"/>
|
||||
<outlet property="symbolTextButton" destination="oaQ-1y-atp" id="Xem-ED-whh"/>
|
||||
|
|
@ -214,7 +208,7 @@
|
|||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="w5U-DZ-TWT" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-2593" y="3368"/>
|
||||
<point key="canvasLocation" x="-2594.4000000000001" y="3367.4662668665669"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17132" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="hIc-I2-PiV">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="hIc-I2-PiV">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17105"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17124"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
|
|
@ -16,35 +16,54 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TH8-Ct-wSJ">
|
||||
<rect key="frame" x="134.5" y="61" width="106" height="30"/>
|
||||
<state key="normal" title="Choose a Color"/>
|
||||
<connections>
|
||||
<action selector="presentColorPicker:" destination="hIc-I2-PiV" eventType="touchUpInside" id="iGk-NE-lKX"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jh0-Q9-KCm">
|
||||
<rect key="frame" x="124.5" y="108" width="126" height="98"/>
|
||||
<rect key="frame" x="96" y="68" width="183" height="161"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="98" id="6aO-dy-av9"/>
|
||||
<constraint firstAttribute="width" constant="126" id="TyY-A7-xPQ"/>
|
||||
<constraint firstAttribute="height" constant="161" id="74l-f9-un2"/>
|
||||
<constraint firstAttribute="width" constant="183" id="Sx7-8a-1h0"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AUx-k8-3oK">
|
||||
<rect key="frame" x="18" y="68" width="43" height="30"/>
|
||||
<state key="normal" title="Picker"/>
|
||||
<connections>
|
||||
<action selector="presentColorPickerByButton:" destination="hIc-I2-PiV" eventType="touchUpInside" id="e17-Pb-PoT"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="coy-eq-4c1">
|
||||
<rect key="frame" x="18" y="106" width="32" height="32"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="32" id="0E9-RA-Leh"/>
|
||||
<constraint firstAttribute="width" constant="32" id="92h-Fu-TUK"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<viewLayoutGuide key="safeArea" id="4kY-K9-p6O"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="jh0-Q9-KCm" firstAttribute="top" secondItem="TH8-Ct-wSJ" secondAttribute="bottom" constant="17" id="N8H-6M-FNl"/>
|
||||
<constraint firstItem="TH8-Ct-wSJ" firstAttribute="top" secondItem="4kY-K9-p6O" secondAttribute="top" constant="17" id="at2-nG-mUW"/>
|
||||
<constraint firstItem="jh0-Q9-KCm" firstAttribute="centerX" secondItem="4kY-K9-p6O" secondAttribute="centerX" id="kdQ-0C-0zo"/>
|
||||
<constraint firstItem="TH8-Ct-wSJ" firstAttribute="centerX" secondItem="4kY-K9-p6O" secondAttribute="centerX" id="w18-a2-nCa"/>
|
||||
<constraint firstItem="AUx-k8-3oK" firstAttribute="top" secondItem="4kY-K9-p6O" secondAttribute="top" constant="24" id="Djw-Wh-pTC"/>
|
||||
<constraint firstItem="jh0-Q9-KCm" firstAttribute="centerX" secondItem="4kY-K9-p6O" secondAttribute="centerX" id="ONW-ef-5lM"/>
|
||||
<constraint firstItem="AUx-k8-3oK" firstAttribute="leading" secondItem="4kY-K9-p6O" secondAttribute="leading" constant="18" id="RLz-JH-nah"/>
|
||||
<constraint firstItem="coy-eq-4c1" firstAttribute="top" secondItem="AUx-k8-3oK" secondAttribute="bottom" constant="8" symbolic="YES" id="V1j-pI-jh1"/>
|
||||
<constraint firstItem="jh0-Q9-KCm" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="AUx-k8-3oK" secondAttribute="trailing" constant="8" symbolic="YES" id="fUw-oV-IOc"/>
|
||||
<constraint firstItem="coy-eq-4c1" firstAttribute="leading" secondItem="4kY-K9-p6O" secondAttribute="leading" constant="18" id="gik-Ns-AOy"/>
|
||||
<constraint firstItem="jh0-Q9-KCm" firstAttribute="top" secondItem="4kY-K9-p6O" secondAttribute="top" constant="24" id="rM5-Cm-nV4"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Color Picker" id="dbS-ug-Aqt"/>
|
||||
<navigationItem key="navigationItem" title="Color Picker" id="dbS-ug-Aqt">
|
||||
<barButtonItem key="rightBarButtonItem" title="Picker" id="Fs7-Gm-UHj">
|
||||
<connections>
|
||||
<action selector="presentColorPickerByBarButton:" destination="hIc-I2-PiV" id="qhG-t5-kTb"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
<outlet property="colorView" destination="jh0-Q9-KCm" id="2zU-fc-9B4"/>
|
||||
<outlet property="pickerButton" destination="AUx-k8-3oK" id="7Pq-2T-USs"/>
|
||||
<outlet property="pickerWellView" destination="coy-eq-4c1" id="CbM-kw-T4C"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="TYZ-t7-BMO" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17132" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="hIc-I2-PiV">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="hIc-I2-PiV">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17105"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17502"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
|
|
@ -17,18 +17,25 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TH8-Ct-wSJ">
|
||||
<rect key="frame" x="137.5" y="61" width="100" height="30"/>
|
||||
<state key="normal" title="Choose a Font"/>
|
||||
<rect key="frame" x="93" y="61" width="189" height="30"/>
|
||||
<state key="normal" title="UIFontPickerViewController"/>
|
||||
<connections>
|
||||
<action selector="presentFontPicker:" destination="hIc-I2-PiV" eventType="touchUpInside" id="czp-14-7Tz"/>
|
||||
<action selector="presentFontPicker:" destination="hIc-I2-PiV" eventType="touchUpInside" id="spL-iY-EMO"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Emd-Kd-874">
|
||||
<rect key="frame" x="87.5" y="99" width="200" height="30"/>
|
||||
<state key="normal" title="UITextFormattingCoordinator"/>
|
||||
<connections>
|
||||
<action selector="presentTextFormattingCoordinator:" destination="hIc-I2-PiV" eventType="touchUpInside" id="0Hz-Yf-RT0"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f9m-D2-c8M">
|
||||
<rect key="frame" x="16" y="123" width="343" height="62"/>
|
||||
<rect key="frame" x="16" y="149" width="343" height="62"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="62" id="4CA-4b-9B5"/>
|
||||
<constraint firstAttribute="height" constant="62" id="fpd-wp-gfW"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="28"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
|
|
@ -36,17 +43,20 @@
|
|||
<viewLayoutGuide key="safeArea" id="4kY-K9-p6O"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="f9m-D2-c8M" firstAttribute="centerX" secondItem="TH8-Ct-wSJ" secondAttribute="centerX" id="9fN-ms-POu"/>
|
||||
<constraint firstItem="f9m-D2-c8M" firstAttribute="top" secondItem="TH8-Ct-wSJ" secondAttribute="bottom" constant="32" id="KAj-zo-YPU"/>
|
||||
<constraint firstItem="TH8-Ct-wSJ" firstAttribute="top" secondItem="4kY-K9-p6O" secondAttribute="top" constant="17" id="at2-nG-mUW"/>
|
||||
<constraint firstItem="TH8-Ct-wSJ" firstAttribute="centerX" secondItem="4kY-K9-p6O" secondAttribute="centerX" id="w18-a2-nCa"/>
|
||||
<constraint firstItem="f9m-D2-c8M" firstAttribute="leading" secondItem="EB5-Ny-mbq" secondAttribute="leadingMargin" id="yIz-ce-gY6"/>
|
||||
<constraint firstItem="Emd-Kd-874" firstAttribute="centerX" secondItem="4kY-K9-p6O" secondAttribute="centerX" id="6S2-69-Oan"/>
|
||||
<constraint firstItem="TH8-Ct-wSJ" firstAttribute="centerX" secondItem="4kY-K9-p6O" secondAttribute="centerX" id="AlX-px-iYg"/>
|
||||
<constraint firstItem="Emd-Kd-874" firstAttribute="top" secondItem="TH8-Ct-wSJ" secondAttribute="bottom" constant="8" symbolic="YES" id="FTD-D9-pXU"/>
|
||||
<constraint firstItem="f9m-D2-c8M" firstAttribute="leading" secondItem="4kY-K9-p6O" secondAttribute="leading" constant="16" id="WVp-rd-POP"/>
|
||||
<constraint firstItem="TH8-Ct-wSJ" firstAttribute="top" secondItem="4kY-K9-p6O" secondAttribute="top" constant="17" id="ki0-al-5RB"/>
|
||||
<constraint firstItem="4kY-K9-p6O" firstAttribute="trailing" secondItem="f9m-D2-c8M" secondAttribute="trailing" constant="16" id="nc9-ZR-wIK"/>
|
||||
<constraint firstItem="f9m-D2-c8M" firstAttribute="top" secondItem="Emd-Kd-874" secondAttribute="bottom" constant="20" id="x67-OX-OFc"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Font Picker" id="dbS-ug-Aqt"/>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
<outlet property="fontLabel" destination="f9m-D2-c8M" id="OJy-K9-zVC"/>
|
||||
<outlet property="textFormatterButton" destination="Emd-Kd-874" id="LMw-Tk-Bfk"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="TYZ-t7-BMO" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
|
|
|||
|
|
@ -77,4 +77,5 @@ Strings used across the application via the NSLocalizedString API.
|
|||
"DefaultPageControlTitle" = "Page Control";
|
||||
"CustomPageControlTitle" = "Custom Page Control";
|
||||
|
||||
"SwitchTitle" = "Title";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="K8w-Uq-R9J">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17503.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="K8w-Uq-R9J">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14766.15"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17502"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
|
@ -28,20 +29,20 @@
|
|||
<rect key="frame" x="0.0" y="30.5" width="343" height="34"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Detail" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="St9-G8-PkK">
|
||||
<rect key="frame" x="0.0" y="0.0" width="105" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="104" height="34"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="PKs-Ty-pao">
|
||||
<rect key="frame" x="115" y="0.0" width="176" height="34"/>
|
||||
<rect key="frame" x="114" y="0.0" width="177.5" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EZd-jG-vsf">
|
||||
<rect key="frame" x="301" y="0.0" width="42" height="34"/>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EZd-jG-vsf">
|
||||
<rect key="frame" x="301.5" y="0.0" width="41.5" height="34"/>
|
||||
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
|
||||
<state key="normal" image="stepper_increment"/>
|
||||
<state key="normal" image="plus" catalog="system"/>
|
||||
<connections>
|
||||
<action selector="showFurtherDetail:" destination="K8w-Uq-R9J" eventType="touchUpInside" id="zM0-ux-Y4O"/>
|
||||
</connections>
|
||||
|
|
@ -52,20 +53,20 @@
|
|||
<rect key="frame" x="0.0" y="74.5" width="343" height="34"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Further Detail" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iqg-vd-ycM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="105" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="104" height="34"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Iva-ta-sqG">
|
||||
<rect key="frame" x="115" y="0.0" width="176" height="34"/>
|
||||
<rect key="frame" x="114" y="0.0" width="177.5" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EyS-LN-1u7">
|
||||
<rect key="frame" x="301" y="0.0" width="42" height="34"/>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EyS-LN-1u7">
|
||||
<rect key="frame" x="301.5" y="0.0" width="41.5" height="34"/>
|
||||
<inset key="contentEdgeInsets" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
|
||||
<state key="normal" image="stepper_decrement"/>
|
||||
<state key="normal" image="minus" catalog="system"/>
|
||||
<connections>
|
||||
<action selector="hideFurtherDetail:" destination="K8w-Uq-R9J" eventType="touchUpInside" id="2br-ix-gLo"/>
|
||||
</connections>
|
||||
|
|
@ -84,26 +85,26 @@
|
|||
</constraints>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HBg-iH-Es9">
|
||||
<rect key="frame" x="16" y="206.5" width="343" height="42"/>
|
||||
<rect key="frame" x="16" y="206.5" width="343" height="40"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Add/remove views" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kvo-0P-2un">
|
||||
<rect key="frame" x="0.0" y="0.0" width="259" height="42"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="260" height="40"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="252" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Got-h9-YTc" userLabel="Add button">
|
||||
<rect key="frame" x="259" y="0.0" width="42" height="42"/>
|
||||
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="252" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Got-h9-YTc" userLabel="Add button">
|
||||
<rect key="frame" x="260" y="0.0" width="41.5" height="40"/>
|
||||
<inset key="contentEdgeInsets" minX="10" minY="10" maxX="10" maxY="10"/>
|
||||
<state key="normal" image="stepper_increment"/>
|
||||
<state key="normal" image="plus" catalog="system"/>
|
||||
<connections>
|
||||
<action selector="addArrangedSubviewToStack:" destination="K8w-Uq-R9J" eventType="touchUpInside" id="Gi5-my-DDb"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="253" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YkZ-DW-LIz" userLabel="Remove button">
|
||||
<rect key="frame" x="301" y="0.0" width="42" height="42"/>
|
||||
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="253" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YkZ-DW-LIz" userLabel="Remove button">
|
||||
<rect key="frame" x="301.5" y="0.0" width="41.5" height="40"/>
|
||||
<inset key="contentEdgeInsets" minX="10" minY="10" maxX="10" maxY="10"/>
|
||||
<state key="normal" image="stepper_decrement"/>
|
||||
<state key="normal" image="minus" catalog="system"/>
|
||||
<connections>
|
||||
<action selector="removeArrangedSubviewFromStack:" destination="K8w-Uq-R9J" eventType="touchUpInside" id="4tK-3G-rEB"/>
|
||||
</connections>
|
||||
|
|
@ -111,13 +112,14 @@
|
|||
</subviews>
|
||||
</stackView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="pVr-DZ-tf0">
|
||||
<rect key="frame" x="16" y="256.5" width="343" height="42"/>
|
||||
<rect key="frame" x="16" y="254.5" width="343" height="42"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="42" placeholder="YES" id="7Rt-U8-9u4"/>
|
||||
</constraints>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="FWG-QM-hGj"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstItem="cDn-lT-iQW" firstAttribute="leading" secondItem="Hwb-09-b4P" secondAttribute="leadingMargin" id="0E3-xe-Wem"/>
|
||||
<constraint firstItem="HBg-iH-Es9" firstAttribute="top" secondItem="cDn-lT-iQW" secondAttribute="bottom" constant="20" id="2dx-wn-jkY"/>
|
||||
|
|
@ -129,7 +131,6 @@
|
|||
<constraint firstItem="HBg-iH-Es9" firstAttribute="leading" secondItem="Hwb-09-b4P" secondAttribute="leadingMargin" id="lM1-th-6X7"/>
|
||||
<constraint firstItem="pVr-DZ-tf0" firstAttribute="trailing" secondItem="Hwb-09-b4P" secondAttribute="trailingMargin" id="vPE-u0-sZi"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="FWG-QM-hGj"/>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Stack Views" id="nhS-n7-kRE"/>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
|
|
@ -147,7 +148,10 @@
|
|||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="stepper_decrement" width="22" height="22"/>
|
||||
<image name="stepper_increment" width="22" height="22"/>
|
||||
<image name="minus" catalog="system" width="128" height="24"/>
|
||||
<image name="plus" catalog="system" width="128" height="113"/>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14800.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="zcI-oN-J3j">
|
||||
<device id="retina4_7" orientation="portrait"/>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="zcI-oN-J3j">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14758.1"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17502"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="4ER-nG-feZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
|
||||
<sections>
|
||||
<tableViewSection headerTitle="Default" id="A1X-FU-XOh">
|
||||
<cells>
|
||||
|
|
@ -36,10 +36,31 @@
|
|||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
<tableViewSection headerTitle="Checkbox" id="8tR-h3-BYV" userLabel="Checkbox">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="OTP-c3-orK">
|
||||
<rect key="frame" x="0.0" y="147.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="OTP-c3-orK" id="vdP-Xc-eFr">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vfi-lH-jjc">
|
||||
<rect key="frame" x="163.5" y="6.5" width="51" height="31"/>
|
||||
</switch>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="centerY" secondItem="vfi-lH-jjc" secondAttribute="centerY" id="6Nc-5B-mw0"/>
|
||||
<constraint firstAttribute="centerX" secondItem="vfi-lH-jjc" secondAttribute="centerX" constant="-0.5" id="Myr-tg-Jpi"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
<tableViewSection headerTitle="Tinted" id="CBk-hR-hJd">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="yon-1U-p9a">
|
||||
<rect key="frame" x="0.0" y="147.5" width="375" height="44"/>
|
||||
<rect key="frame" x="0.0" y="239.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="yon-1U-p9a" id="wAh-qG-cWE">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
|
|
@ -66,6 +87,7 @@
|
|||
<navigationItem key="navigationItem" title="Switches" id="E77-79-RWj"/>
|
||||
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
|
||||
<connections>
|
||||
<outlet property="checkBoxSwitch" destination="vfi-lH-jjc" id="QYU-aB-c9V"/>
|
||||
<outlet property="defaultSwitch" destination="juD-bH-XxM" id="U7B-Ar-wQR"/>
|
||||
<outlet property="tintedSwitch" destination="w5d-qp-nmC" id="8p2-vj-WvA"/>
|
||||
</connections>
|
||||
|
|
@ -75,4 +97,9 @@
|
|||
<point key="canvasLocation" x="6131" y="3368"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<systemColor name="groupTableViewBackgroundColor">
|
||||
<color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<br><br>
|
||||
<br>
|
||||
<h1>This is HTML content inside a <u>WKWebView</u>.</h1>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -64,14 +64,12 @@ class ButtonViewController: UITableViewController {
|
|||
func configureImageButton() {
|
||||
// To create this button in code you can use `UIButton.init(type: .system)`.
|
||||
|
||||
// Remove the title text.
|
||||
imageButton.setTitle("", for: .normal)
|
||||
|
||||
imageButton.tintColor = UIColor.systemPurple
|
||||
|
||||
let imageButtonNormalImage = #imageLiteral(resourceName: "x_icon")
|
||||
imageButton.setImage(imageButtonNormalImage, for: .normal)
|
||||
|
||||
// Set the tint color to the button's image.
|
||||
if let image = UIImage(named: "x_icon") {
|
||||
let imageButtonNormalImage = image.withTintColor(.systemPurple)
|
||||
imageButton.setImage(imageButtonNormalImage, for: .normal)
|
||||
}
|
||||
|
||||
// Add an accessibility label to the image.
|
||||
imageButton.accessibilityLabel = NSLocalizedString("X", comment: "")
|
||||
|
||||
|
|
@ -83,7 +81,6 @@ class ButtonViewController: UITableViewController {
|
|||
|
||||
// Set the button's title for normal state.
|
||||
let normalTitleAttributes: [NSAttributedString.Key: Any] = [
|
||||
NSAttributedString.Key.foregroundColor: UIColor.systemBlue,
|
||||
NSAttributedString.Key.strikethroughStyle: NSUnderlineStyle.single.rawValue
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,16 +11,59 @@ class ColorPickerViewController: UIViewController, UIColorPickerViewControllerDe
|
|||
|
||||
// MARK: - Properties
|
||||
|
||||
var colorWell: UIColorWell!
|
||||
var colorPicker: UIColorPickerViewController!
|
||||
@IBOutlet var colorView: UIView!
|
||||
|
||||
@IBOutlet var pickerButton: UIButton! // UIButton to present the picker.
|
||||
@IBOutlet var pickerWellView: UIView! // UIView placeholder to hold the UIColorWell.
|
||||
|
||||
@IBOutlet var colorView: UIView!
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
configureColorPicker()
|
||||
configureColorWell()
|
||||
|
||||
// For iOS, the picker button in the main view is not used, the color picker is presented from the navigation bar.
|
||||
if navigationController!.traitCollection.userInterfaceIdiom != .mac {
|
||||
pickerButton.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UIColorWell
|
||||
|
||||
func colorWellHandler(action: UIAction) {
|
||||
if let colorWell = action.sender as? UIColorWell {
|
||||
colorView.backgroundColor = colorWell.selectedColor
|
||||
}
|
||||
}
|
||||
|
||||
func configureColorWell() {
|
||||
|
||||
/** Note: Both color well and picker buttons achieve the same thing, presenting the color picker.
|
||||
But one presents it with a color well control, the other by a bar button item.
|
||||
*/
|
||||
let colorWellAction = UIAction(title: "", handler: colorWellHandler)
|
||||
colorWell =
|
||||
UIColorWell(frame: CGRect(x: 0, y: 0, width: 32, height: 32),
|
||||
primaryAction: colorWellAction)
|
||||
|
||||
// For Mac Catalyst, the UIColorWell is placed in the main view.
|
||||
if navigationController!.traitCollection.userInterfaceIdiom == .mac {
|
||||
pickerWellView.addSubview(colorWell)
|
||||
} else {
|
||||
// For iOS, the UIColorWell is placed inside the navigation bar as a UIBarButtonItem.
|
||||
let colorWellBarItem = UIBarButtonItem(customView: colorWell)
|
||||
let fixedBarItem = UIBarButtonItem.fixedSpace(20.0)
|
||||
navigationItem.rightBarButtonItems!.append(fixedBarItem)
|
||||
navigationItem.rightBarButtonItems!.append(colorWellBarItem)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UIColorPickerViewController
|
||||
|
||||
func configureColorPicker() {
|
||||
colorPicker = UIColorPickerViewController()
|
||||
|
|
@ -28,8 +71,22 @@ class ColorPickerViewController: UIViewController, UIColorPickerViewControllerDe
|
|||
colorPicker.selectedColor = UIColor.blue
|
||||
colorPicker.delegate = self
|
||||
}
|
||||
|
||||
@IBAction func presentColorPicker(_: AnyObject) {
|
||||
|
||||
// Present the color picker from the UIBarButtonItem, iOS only.
|
||||
// This will present it as a popover (preferred), or for compact mode as a modal sheet.
|
||||
@IBAction func presentColorPickerByBarButton(_ sender: UIBarButtonItem) {
|
||||
colorPicker.modalPresentationStyle = UIModalPresentationStyle.popover
|
||||
let popover: UIPopoverPresentationController = colorPicker.popoverPresentationController!
|
||||
popover.barButtonItem = sender
|
||||
present(colorPicker, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// Present the color picker from the UIButton, Mac Catalyst only.
|
||||
// This will present it as a popover (preferred), or for compact mode as a modal sheet.
|
||||
@IBAction func presentColorPickerByButton(_ sender: UIButton) {
|
||||
colorPicker.modalPresentationStyle = UIModalPresentationStyle.popover
|
||||
let popover: UIPopoverPresentationController = colorPicker.popoverPresentationController!
|
||||
popover.sourceView = sender
|
||||
present(colorPicker, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,19 +7,35 @@ A view controller that demonstrates how to use `UIFontPickerViewController`.
|
|||
|
||||
import UIKit
|
||||
|
||||
class FontPickerViewController: UIViewController, UIFontPickerViewControllerDelegate {
|
||||
class FontPickerViewController: UIViewController {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
var fontPicker: UIFontPickerViewController!
|
||||
var textFormatter: UITextFormattingCoordinator!
|
||||
|
||||
@IBOutlet var fontLabel: UILabel!
|
||||
@IBOutlet var textFormatterButton: UIButton!
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
fontLabel.text = NSLocalizedString("SampleFontTitle", comment: "")
|
||||
|
||||
configureFontPicker()
|
||||
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
// UITextFormattingCoordinator's toggleFontPanel is available only for macOS.
|
||||
textFormatterButton.isHidden = true
|
||||
#endif
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
configureTextFormatter()
|
||||
}
|
||||
|
||||
func configureFontPicker() {
|
||||
|
|
@ -30,25 +46,63 @@ class FontPickerViewController: UIViewController, UIFontPickerViewControllerDele
|
|||
|
||||
fontPicker = UIFontPickerViewController(configuration: configuration)
|
||||
fontPicker.delegate = self
|
||||
}
|
||||
|
||||
@IBAction func presentFontPicker(_: AnyObject) {
|
||||
present(fontPicker, animated: true)
|
||||
fontPicker.modalPresentationStyle = UIModalPresentationStyle.popover
|
||||
}
|
||||
|
||||
// MARK: - UIFontPickerViewControllerDelegate
|
||||
func configureTextFormatter() {
|
||||
if textFormatter == nil {
|
||||
guard let scene = self.view.window?.windowScene else { return }
|
||||
let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: fontLabel.font as Any]
|
||||
textFormatter = UITextFormattingCoordinator(for: scene)
|
||||
textFormatter.delegate = self
|
||||
textFormatter.setSelectedAttributes(attributes, isMultiple: true)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func presentFontPicker(_ sender: Any) {
|
||||
if let button = sender as? UIButton {
|
||||
let popover: UIPopoverPresentationController = fontPicker.popoverPresentationController!
|
||||
popover.sourceView = button
|
||||
present(fontPicker, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func presentTextFormattingCoordinator(_ sender: Any) {
|
||||
if !UITextFormattingCoordinator.isFontPanelVisible {
|
||||
UITextFormattingCoordinator.toggleFontPanel(sender)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UIFontPickerViewControllerDelegate
|
||||
|
||||
extension FontPickerViewController: UIFontPickerViewControllerDelegate {
|
||||
|
||||
func fontPickerViewControllerDidCancel(_ viewController: UIFontPickerViewController) {
|
||||
//..
|
||||
}
|
||||
|
||||
func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) {
|
||||
guard let fontDescriptor = viewController.selectedFontDescriptor else { return }
|
||||
let font = UIFont(descriptor: fontDescriptor, size: 48.0)
|
||||
let font = UIFont(descriptor: fontDescriptor, size: 28.0)
|
||||
fontLabel.font = font
|
||||
fontLabel.text = NSLocalizedString("SampleFontTitle", comment: "")
|
||||
|
||||
Swift.debugPrint("Chosen font: \(font)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UITextFormattingCoordinatorDelegate
|
||||
|
||||
extension FontPickerViewController: UITextFormattingCoordinatorDelegate {
|
||||
|
||||
override func updateTextAttributes(conversionHandler: ([NSAttributedString.Key: Any]) -> [NSAttributedString.Key: Any]) {
|
||||
guard let oldLabelText = fontLabel.attributedText else { return }
|
||||
let newString = NSMutableAttributedString(string: oldLabelText.string)
|
||||
oldLabelText.enumerateAttributes(in: NSRange(location: 0, length: oldLabelText.length),
|
||||
options: []) { (attributeDictionary, range, stop) in
|
||||
newString.setAttributes(conversionHandler(attributeDictionary), range: range)
|
||||
}
|
||||
fontLabel.attributedText = newString
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,11 +45,20 @@ class OutlineViewController: UIViewController {
|
|||
configureCollectionView()
|
||||
configureDataSource()
|
||||
|
||||
// Add a translucent background to the primary view controller for the Mac.
|
||||
splitViewController!.primaryBackgroundStyle = .sidebar
|
||||
view.backgroundColor = UIColor.clear
|
||||
|
||||
// Listen for when a split view controller is expanded or collapsed.
|
||||
NotificationCenter.default.addObserver(self,
|
||||
selector: #selector(showDetailTargetDidChange(_:)),
|
||||
name: UIViewController.showDetailTargetDidChangeNotification,
|
||||
object: nil)
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(showDetailTargetDidChange(_:)),
|
||||
name: UIViewController.showDetailTargetDidChangeNotification,
|
||||
object: nil)
|
||||
|
||||
if navigationController!.traitCollection.userInterfaceIdiom == .mac {
|
||||
navigationController!.navigationBar.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
// Posted when a split view controller is expanded or collapsed.
|
||||
|
|
@ -65,75 +74,105 @@ class OutlineViewController: UIViewController {
|
|||
NotificationCenter.default.removeObserver(self, name: UIViewController.showDetailTargetDidChangeNotification, object: nil)
|
||||
}
|
||||
|
||||
lazy var controlsOutlineItem: OutlineItem = {
|
||||
var controlsSubItems = [
|
||||
OutlineItem(title: NSLocalizedString("ButtonsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ButtonViewController"),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("PageControlTitle", comment: ""), imageName: nil, subitems: [
|
||||
OutlineItem(title: NSLocalizedString("DefaultPageControlTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DefaultPageControlViewController"),
|
||||
OutlineItem(title: NSLocalizedString("CustomPageControlTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "CustomPageControlViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("SearchBarsTitle", comment: ""), imageName: nil, subitems: [
|
||||
OutlineItem(title: NSLocalizedString("DefaultSearchBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DefaultSearchBarViewController"),
|
||||
OutlineItem(title: NSLocalizedString("CustomSearchBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "CustomSearchBarViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("SegmentedControlsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "SegmentedControlViewController"),
|
||||
OutlineItem(title: NSLocalizedString("SlidersTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "SliderViewController"),
|
||||
OutlineItem(title: NSLocalizedString("SwitchesTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "SwitchViewController"),
|
||||
OutlineItem(title: NSLocalizedString("TextFieldsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "TextFieldViewController")
|
||||
]
|
||||
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
/** Because this sample has "Optimize Interface for Mac" turned on -
|
||||
UIStepper class is not supported when running Mac Catalyst apps in the Mac idiom.
|
||||
*/
|
||||
let stepperItem =
|
||||
OutlineItem(title: NSLocalizedString("SteppersTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "StepperViewController")
|
||||
controlsSubItems.append(stepperItem)
|
||||
#endif
|
||||
|
||||
return OutlineItem(title: "Controls", imageName: "slider.horizontal.3", subitems: controlsSubItems)
|
||||
}()
|
||||
|
||||
lazy var pickersOutlineItem: OutlineItem = {
|
||||
var pickerSubItems = [
|
||||
OutlineItem(title: NSLocalizedString("DatePickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DatePickerController"),
|
||||
OutlineItem(title: NSLocalizedString("ColorPickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ColorPickerViewController"),
|
||||
OutlineItem(title: NSLocalizedString("FontPickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "FontPickerViewController"),
|
||||
OutlineItem(title: NSLocalizedString("ImagePickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ImagePickerViewController")
|
||||
]
|
||||
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
/** Because this sample has "Optimize Interface for Mac" turned on -
|
||||
UIPickerView class is not supported when running Mac Catalyst apps in the Mac idiom.
|
||||
*/
|
||||
let pickerViewItem =
|
||||
OutlineItem(title: NSLocalizedString("PickerViewTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "PickerViewController")
|
||||
pickerSubItems.append(pickerViewItem)
|
||||
#endif
|
||||
|
||||
return OutlineItem(title: "Pickers", imageName: "list.bullet", subitems: pickerSubItems)
|
||||
}()
|
||||
|
||||
lazy var viewsOutlineItem: OutlineItem = {
|
||||
OutlineItem(title: "Views", imageName: "rectangle.stack.person.crop", subitems: [
|
||||
OutlineItem(title: NSLocalizedString("ActivityIndicatorsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ActivityIndicatorViewController"),
|
||||
OutlineItem(title: NSLocalizedString("AlertControllersTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "AlertControllerViewController"),
|
||||
OutlineItem(title: NSLocalizedString("ImageViewTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ImageViewController"),
|
||||
OutlineItem(title: NSLocalizedString("ProgressViewsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ProgressViewController"),
|
||||
OutlineItem(title: NSLocalizedString("StackViewsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "StackViewController"),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("ToolbarsTitle", comment: ""), imageName: nil, subitems: [
|
||||
OutlineItem(title: NSLocalizedString("DefaultToolBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DefaultToolbarViewController"),
|
||||
OutlineItem(title: NSLocalizedString("TintedToolbarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "TintedToolbarViewController"),
|
||||
OutlineItem(title: NSLocalizedString("CustomToolbarBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "CustomToolbarViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("WebViewTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "WebViewController")
|
||||
])
|
||||
}()
|
||||
|
||||
private lazy var menuItems: [OutlineItem] = {
|
||||
return [
|
||||
OutlineItem(title: "Controls", imageName: "slider.horizontal.3", subitems: [
|
||||
OutlineItem(title: NSLocalizedString("ButtonsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ButtonViewController"),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("PageControlTitle", comment: ""), imageName: nil, subitems: [
|
||||
OutlineItem(title: NSLocalizedString("DefaultPageControlTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DefaultPageControlViewController"),
|
||||
OutlineItem(title: NSLocalizedString("CustomPageControlTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "CustomPageControlViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("SearchBarsTitle", comment: ""), imageName: nil, subitems: [
|
||||
OutlineItem(title: NSLocalizedString("DefaultSearchBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DefaultSearchBarViewController"),
|
||||
OutlineItem(title: NSLocalizedString("CustomSearchBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "CustomSearchBarViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("SegmentedControlsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "SegmentedControlViewController"),
|
||||
OutlineItem(title: NSLocalizedString("SlidersTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "SliderViewController"),
|
||||
OutlineItem(title: NSLocalizedString("SteppersTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "StepperViewController"),
|
||||
OutlineItem(title: NSLocalizedString("SwitchesTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "SwitchViewController"),
|
||||
OutlineItem(title: NSLocalizedString("TextFieldsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "TextFieldViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: "Views", imageName: "rectangle.stack.person.crop", subitems: [
|
||||
OutlineItem(title: NSLocalizedString("ActivityIndicatorsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ActivityIndicatorViewController"),
|
||||
OutlineItem(title: NSLocalizedString("AlertControllersTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "AlertControllerViewController"),
|
||||
OutlineItem(title: NSLocalizedString("ImageViewTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ImageViewController"),
|
||||
OutlineItem(title: NSLocalizedString("ProgressViewsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ProgressViewController"),
|
||||
OutlineItem(title: NSLocalizedString("StackViewsTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "StackViewController"),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("ToolbarsTitle", comment: ""), imageName: nil, subitems: [
|
||||
OutlineItem(title: NSLocalizedString("DefaultToolBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DefaultToolbarViewController"),
|
||||
OutlineItem(title: NSLocalizedString("TintedToolbarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "TintedToolbarViewController"),
|
||||
OutlineItem(title: NSLocalizedString("CustomToolbarBarTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "CustomToolbarViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: NSLocalizedString("WebViewTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "WebViewController")
|
||||
]),
|
||||
|
||||
OutlineItem(title: "Pickers", imageName: "list.bullet", subitems: [
|
||||
OutlineItem(title: NSLocalizedString("DatePickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "DatePickerController"),
|
||||
OutlineItem(title: NSLocalizedString("PickerViewTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "PickerViewController"),
|
||||
OutlineItem(title: NSLocalizedString("ColorPickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ColorPickerViewController"),
|
||||
OutlineItem(title: NSLocalizedString("FontPickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "FontPickerViewController"),
|
||||
OutlineItem(title: NSLocalizedString("ImagePickerTitle", comment: ""), imageName: nil,
|
||||
storyboardName: "ImagePickerViewController")
|
||||
])
|
||||
controlsOutlineItem,
|
||||
viewsOutlineItem,
|
||||
pickersOutlineItem
|
||||
]
|
||||
}()
|
||||
|
||||
|
|
@ -148,7 +187,6 @@ extension OutlineViewController {
|
|||
UICollectionView(frame: view.bounds, collectionViewLayout: generateLayout())
|
||||
view.addSubview(collectionView)
|
||||
collectionView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
|
||||
collectionView.backgroundColor = .systemBackground
|
||||
self.outlineCollectionView = collectionView
|
||||
collectionView.delegate = self
|
||||
}
|
||||
|
|
@ -233,7 +271,11 @@ extension OutlineViewController: UICollectionViewDelegate {
|
|||
private func pushOrPresentViewController(viewController: UIViewController) {
|
||||
if splitViewWantsToShowDetail() {
|
||||
let navVC = UINavigationController(rootViewController: viewController)
|
||||
splitViewController?.showDetailViewController(navVC, sender: navVC) // Replace the detail view controller.
|
||||
splitViewController?.showDetailViewController(navVC, sender: navVC) // Replace the detail view controller.
|
||||
|
||||
if navigationController!.traitCollection.userInterfaceIdiom == .mac {
|
||||
navVC.navigationBar.isHidden = true
|
||||
}
|
||||
} else {
|
||||
navigationController?.pushViewController(viewController, animated: true) // Just push instead of replace.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,4 +106,35 @@ class ProgressViewController: UITableViewController {
|
|||
tintedProgressView.progressTintColor = UIColor.systemPurple
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted progress view for macOS, it does not exist.
|
||||
if section == 2 {
|
||||
return ""
|
||||
} else {
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
||||
override func tableView(_ tableView: UITableView,
|
||||
heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted progress view for macOS, it does not exist.
|
||||
if indexPath.section == 2 {
|
||||
return 0
|
||||
} else {
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,25 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, UISplitViewControllerDe
|
|||
The recommended approach is for the SceneDelegate to retain the scene's window.
|
||||
*/
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
guard let windowScene = (scene as? UIWindowScene) else { return }
|
||||
|
||||
if let splitViewController = window!.rootViewController as? UISplitViewController {
|
||||
splitViewController.delegate = self
|
||||
|
||||
splitViewController.preferredDisplayMode = .oneBesideSecondary
|
||||
splitViewController.presentsWithGesture = false
|
||||
|
||||
if let navController = splitViewController.viewControllers[1] as? UINavigationController {
|
||||
// For the Mac, remove the title bar and navigation bar.
|
||||
#if targetEnvironment(macCatalyst)
|
||||
if let titlebar = windowScene.titlebar {
|
||||
titlebar.titleVisibility = .hidden
|
||||
titlebar.toolbar = nil
|
||||
}
|
||||
// Hide the navigation bar on the Mac.
|
||||
navController.navigationBar.isHidden = true
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,4 +132,35 @@ class SegmentedControlViewController: UITableViewController {
|
|||
func selectedSegmentDidChange(_ segmentedControl: UISegmentedControl) {
|
||||
print("The selected segment changed for: \(segmentedControl).")
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted segmented control for macOS, it does not exist.
|
||||
if section == 1 {
|
||||
return ""
|
||||
} else {
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
||||
override func tableView(_ tableView: UITableView,
|
||||
heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted segmented control for macOS, it does not exist.
|
||||
if indexPath.section == 1 {
|
||||
return 0
|
||||
} else {
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,27 +21,49 @@ class SliderViewController: UITableViewController {
|
|||
super.viewDidLoad()
|
||||
|
||||
configureDefaultSlider()
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
/** Only show for the first table cell (default slider).
|
||||
Because this sample has "Optimize Interface for Mac" turned on -
|
||||
UISlider class: tinted, custom, and max/min image, are not supported when running Mac Catalyst apps in the Mac idiom.
|
||||
*/
|
||||
configureTintedSlider()
|
||||
configureCustomSlider()
|
||||
configureMinMaxImageSlider()
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - Configuration
|
||||
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
/** Only show for the first table cell (default slider).
|
||||
Because this sample has "Optimize Interface for Mac" turned on -
|
||||
UISlider class: tinted, custom, and max/min image, are not supported when running Mac Catalyst apps in the Mac idiom.
|
||||
*/
|
||||
return 1
|
||||
#else
|
||||
return super.numberOfSections(in: tableView)
|
||||
#endif
|
||||
}
|
||||
|
||||
func configureDefaultSlider() {
|
||||
defaultSlider.minimumValue = 0
|
||||
defaultSlider.maximumValue = 100
|
||||
defaultSlider.value = 42
|
||||
defaultSlider.isContinuous = true
|
||||
|
||||
defaultSlider.addTarget(self, action: #selector(SliderViewController.sliderValueDidChange(_:)), for: .valueChanged)
|
||||
defaultSlider.addTarget(self,
|
||||
action: #selector(SliderViewController.sliderValueDidChange(_:)),
|
||||
for: .valueChanged)
|
||||
}
|
||||
|
||||
func configureTintedSlider() {
|
||||
tintedSlider.minimumTrackTintColor = UIColor.systemBlue
|
||||
tintedSlider.maximumTrackTintColor = UIColor.systemPurple
|
||||
|
||||
tintedSlider.addTarget(self, action: #selector(SliderViewController.sliderValueDidChange(_:)), for: .valueChanged)
|
||||
tintedSlider.addTarget(self,
|
||||
action: #selector(SliderViewController.sliderValueDidChange(_:)),
|
||||
for: .valueChanged)
|
||||
}
|
||||
|
||||
func configureCustomSlider() {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,16 @@ class StepperViewController: UITableViewController {
|
|||
|
||||
// MARK: - Configuration
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Only show for the first table cell (default stepper).
|
||||
// Tinted and Custom steppers do not exist in macOS.
|
||||
return 1
|
||||
#else
|
||||
return super.numberOfSections(in: tableView)
|
||||
#endif
|
||||
}
|
||||
|
||||
func configureDefaultStepper() {
|
||||
defaultStepper.value = 0
|
||||
defaultStepper.minimumValue = 0
|
||||
|
|
@ -41,7 +51,9 @@ class StepperViewController: UITableViewController {
|
|||
defaultStepper.stepValue = 1
|
||||
|
||||
defaultStepperLabel.text = "\(Int(defaultStepper.value))"
|
||||
defaultStepper.addTarget(self, action: #selector(StepperViewController.stepperValueDidChange(_:)), for: .valueChanged)
|
||||
defaultStepper.addTarget(self,
|
||||
action: #selector(StepperViewController.stepperValueDidChange(_:)),
|
||||
for: .valueChanged)
|
||||
}
|
||||
|
||||
func configureTintedStepper() {
|
||||
|
|
@ -50,7 +62,9 @@ class StepperViewController: UITableViewController {
|
|||
tintedStepper.setIncrementImage(tintedStepper.incrementImage(for: .normal), for: .normal)
|
||||
|
||||
tintedStepperLabel.text = "\(Int(tintedStepper.value))"
|
||||
tintedStepper.addTarget(self, action: #selector(StepperViewController.stepperValueDidChange(_:)), for: .valueChanged)
|
||||
tintedStepper.addTarget(self,
|
||||
action: #selector(StepperViewController.stepperValueDidChange(_:)),
|
||||
for: .valueChanged)
|
||||
}
|
||||
|
||||
func configureCustomStepper() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class SwitchViewController: UITableViewController {
|
|||
// MARK: - Properties
|
||||
|
||||
@IBOutlet weak var defaultSwitch: UISwitch!
|
||||
|
||||
@IBOutlet weak var checkBoxSwitch: UISwitch!
|
||||
@IBOutlet weak var tintedSwitch: UISwitch!
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
|
@ -20,16 +20,32 @@ class SwitchViewController: UITableViewController {
|
|||
super.viewDidLoad()
|
||||
|
||||
configureDefaultSwitch()
|
||||
configureTintedSwitch()
|
||||
configureCheckboxSwitch() // macOS only.
|
||||
configureTintedSwitch() // iOS only.
|
||||
}
|
||||
|
||||
// MARK: - Configuration
|
||||
|
||||
|
||||
func configureDefaultSwitch() {
|
||||
defaultSwitch.setOn(true, animated: false)
|
||||
|
||||
defaultSwitch.preferredStyle = .sliding
|
||||
|
||||
defaultSwitch.addTarget(self, action: #selector(SwitchViewController.switchValueDidChange(_:)), for: .valueChanged)
|
||||
}
|
||||
|
||||
func configureCheckboxSwitch() {
|
||||
checkBoxSwitch.setOn(true, animated: false)
|
||||
|
||||
checkBoxSwitch.addTarget(self, action: #selector(SwitchViewController.switchValueDidChange(_:)), for: .valueChanged)
|
||||
|
||||
// On the Mac, make sure this control take on the apperance of a checkbox with a title.
|
||||
if traitCollection.userInterfaceIdiom == .mac {
|
||||
checkBoxSwitch.preferredStyle = .checkbox
|
||||
|
||||
// Title on a UISwitch is only supported when running Catalyst apps in the Mac Idiom.
|
||||
checkBoxSwitch.title = NSLocalizedString("SwitchTitle", comment: "")
|
||||
}
|
||||
}
|
||||
|
||||
func configureTintedSwitch() {
|
||||
tintedSwitch.tintColor = UIColor.systemBlue
|
||||
|
|
@ -37,6 +53,54 @@ class SwitchViewController: UITableViewController {
|
|||
tintedSwitch.thumbTintColor = UIColor.systemPurple
|
||||
|
||||
tintedSwitch.addTarget(self, action: #selector(SwitchViewController.switchValueDidChange(_:)), for: .valueChanged)
|
||||
|
||||
// Note that on the Mac, tinted switches are not possible, so we hide the tinted one.
|
||||
if traitCollection.userInterfaceIdiom == .mac {
|
||||
tintedSwitch.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted switch control for macOS, it does not exist.
|
||||
if section == 2 {
|
||||
return ""
|
||||
} else {
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
}
|
||||
#else
|
||||
// Don't show checkbox switch control for iOS, it does not exist.
|
||||
if section == 1 {
|
||||
return ""
|
||||
} else {
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView,
|
||||
heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show tinted switch control for macOS, it does not exist.
|
||||
if indexPath.section == 2 {
|
||||
return 0
|
||||
} else {
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
}
|
||||
#else
|
||||
// Don't show checkbox switch control for iOS, it does not exist.
|
||||
if indexPath.section == 1 {
|
||||
return 0
|
||||
} else {
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class TextFieldViewController: UITableViewController {
|
|||
textField.placeholder = NSLocalizedString("Placeholder text", comment: "")
|
||||
textField.autocorrectionType = .yes
|
||||
textField.returnKeyType = .done
|
||||
textField.clearButtonMode = .never
|
||||
textField.clearButtonMode = .whileEditing
|
||||
}
|
||||
|
||||
func configureTintedTextField() {
|
||||
|
|
@ -92,7 +92,7 @@ class TextFieldViewController: UITableViewController {
|
|||
|
||||
customTextField.background = UIImage(named: "text_field_background")
|
||||
|
||||
// Create a purple button that, when selected, turns the custom text field's text color to purple.
|
||||
// Create a purple button to be used as the right view of the custom text field.
|
||||
let purpleImage = UIImage(named: "text_field_purple_right_view")!
|
||||
let purpleImageButton = UIButton(type: .custom)
|
||||
purpleImageButton.bounds = CGRect(x: 0, y: 0, width: purpleImage.size.width, height: purpleImage.size.height)
|
||||
|
|
@ -104,6 +104,7 @@ class TextFieldViewController: UITableViewController {
|
|||
|
||||
customTextField.placeholder = NSLocalizedString("Placeholder text", comment: "")
|
||||
customTextField.autocorrectionType = .no
|
||||
customTextField.clearButtonMode = .never
|
||||
customTextField.returnKeyType = .done
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +114,37 @@ class TextFieldViewController: UITableViewController {
|
|||
func customTextFieldPurpleButtonClicked() {
|
||||
print("The custom text field's purple right view button was clicked.")
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show text field with custom background for macOS, it does not exist.
|
||||
if section == 4 {
|
||||
return ""
|
||||
} else {
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, titleForHeaderInSection: section)
|
||||
#endif
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
||||
override func tableView(_ tableView: UITableView,
|
||||
heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
// Don't show text field with custom background for macOS, it does not exist.
|
||||
if indexPath.section == 4 {
|
||||
return 0
|
||||
} else {
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
}
|
||||
#else
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,7 @@
|
|||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
|||
Loading…
Reference in a new issue