Font size adjustment
This commit is contained in:
32
App/Document Controls UI/DocumentControlViewController.swift
Normal file
32
App/Document Controls UI/DocumentControlViewController.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// DocumentControlViewController.swift
|
||||
// App
|
||||
//
|
||||
// Created by James Magahern on 9/22/20.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class DocumentControlViewController: UIViewController
|
||||
{
|
||||
let documentControlView = StackView(dimension: .vertical)
|
||||
let fontSizeAdjustView = FontSizeAdjustView()
|
||||
|
||||
static public let preferredWidth = CGFloat(200.0)
|
||||
static public let controlHeight = CGFloat(48.0)
|
||||
|
||||
convenience init() {
|
||||
self.init(nibName: nil, bundle: nil)
|
||||
|
||||
documentControlView.addArrangedSubview(fontSizeAdjustView)
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
self.view = documentControlView
|
||||
}
|
||||
|
||||
override var preferredContentSize: CGSize {
|
||||
get { documentControlView.sizeThatFits(CGSize(width: Self.preferredWidth, height: -1)) }
|
||||
set {}
|
||||
}
|
||||
}
|
||||
58
App/Document Controls UI/FontSizeAdjustView.swift
Normal file
58
App/Document Controls UI/FontSizeAdjustView.swift
Normal file
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// FontSizeAdjustView.swift
|
||||
// App
|
||||
//
|
||||
// Created by James Magahern on 9/22/20.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class FontSizeAdjustView: UIView
|
||||
{
|
||||
let decreaseSizeButton = UIButton(frame: .zero)
|
||||
let increaseSizeButton = UIButton(frame: .zero)
|
||||
let labelView = UILabel(frame: .zero)
|
||||
|
||||
convenience init() {
|
||||
self.init(frame: .zero)
|
||||
|
||||
labelView.textColor = .secondaryLabel
|
||||
labelView.textAlignment = .center
|
||||
labelView.text = "100%"
|
||||
|
||||
tintColor = .black
|
||||
|
||||
decreaseSizeButton.setImage(UIImage(systemName: "minus"), for: .normal)
|
||||
increaseSizeButton.setImage(UIImage(systemName: "plus"), for: .normal)
|
||||
|
||||
addSubview(increaseSizeButton)
|
||||
addSubview(decreaseSizeButton)
|
||||
addSubview(labelView)
|
||||
}
|
||||
|
||||
override func sizeThatFits(_ size: CGSize) -> CGSize {
|
||||
CGSize(width: size.width, height: DocumentControlViewController.controlHeight)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
decreaseSizeButton.frame = CGRect(
|
||||
x: 0.0, y: 0.0,
|
||||
width: bounds.height,
|
||||
height: bounds.height
|
||||
)
|
||||
|
||||
increaseSizeButton.frame = CGRect(
|
||||
x: bounds.width - bounds.height, y: 0.0,
|
||||
width: bounds.height,
|
||||
height: bounds.height
|
||||
)
|
||||
|
||||
labelView.frame = CGRect(
|
||||
x: decreaseSizeButton.frame.maxX, y: 0.0,
|
||||
width: bounds.width - decreaseSizeButton.frame.width - increaseSizeButton.frame.width,
|
||||
height: bounds.height
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user