123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- //
- // CPDFStrikeoutViewController.swift
- // ComPDFKit_Tools
- //
- // Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
- //
- // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
- // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
- // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
- // This notice may not be removed from this file.
- //
- import UIKit
- @objc protocol CPDFStrikeoutViewControllerDelegate: AnyObject {
- @objc optional func strikeoutViewController(_ strikeoutViewController: CPDFStrikeoutViewController, annotStyle: CAnnotStyle)
- }
- class CPDFStrikeoutViewController: CPDFAnnotationBaseViewController {
- weak var delegate: CPDFStrikeoutViewControllerDelegate?
-
- // MARK: - ViewController Methods
-
- override func viewDidLoad() {
- super.viewDidLoad()
- }
-
- override func commomInitTitle() {
- titleLabel?.text = NSLocalizedString("Strikeout", comment: "")
- sampleView?.selecIndex = .highlight
- colorView?.selectedColor = annotStyle?.color
- }
-
- // MARK: - CPDFColorSelectViewDelegate
-
- override func selectColorView(_ select: CPDFColorSelectView, color: UIColor) {
- sampleView?.color = color
- annotStyle?.setColor(color)
-
- if annotStyle != nil {
- delegate?.strikeoutViewController?(self, annotStyle: annotStyle!)
- }
-
- sampleView?.setNeedsDisplay()
- }
-
- // MARK: - CPDFColorPickerViewDelegate
-
- override func pickerView(_ colorPickerView: CPDFColorPickerView, color: UIColor) {
- sampleView?.color = color
- annotStyle?.setColor(color)
-
- if annotStyle != nil {
- delegate?.strikeoutViewController?(self, annotStyle: annotStyle!)
- }
-
- var red: CGFloat = 0
- var green: CGFloat = 0
- var blue: CGFloat = 0
- var alpha: CGFloat = 0
- color.getRed(&red, green: &green, blue: &blue, alpha: &alpha)
- self.opacitySliderView?.opacitySlider?.value = Float(alpha)
- self.opacitySliderView?.startLabel?.text = "\(Int(((self.opacitySliderView?.opacitySlider?.value ?? 0) / 1) * 100))%"
- updatePreferredContentSizeWithTraitCollection(traitCollection: traitCollection)
- }
-
- // MARK: - CPDFOpacitySliderViewDelegate
-
- override func opacitySliderView(_ opacitySliderView: CPDFOpacitySliderView, opacity: CGFloat) {
- sampleView?.opcity = opacity
- annotStyle?.setOpacity(opacity)
- if(annotStyle != nil) {
- delegate?.strikeoutViewController?(self, annotStyle: annotStyle!)
- }
- sampleView?.setNeedsDisplay()
- }
-
- // MARK: - UIColorPickerViewControllerDelegate
-
- @available(iOS 14.0, *)
- func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
- sampleView?.color = viewController.selectedColor
- annotStyle?.setColor(viewController.selectedColor)
- if(annotStyle != nil) {
- delegate?.strikeoutViewController?(self, annotStyle: annotStyle!)
- }
- var red: CGFloat = 0
- var green: CGFloat = 0
- var blue: CGFloat = 0
- var alpha: CGFloat = 0
- viewController.selectedColor.getRed(&red, green: &green, blue: &blue, alpha: &alpha)
- self.opacitySliderView?.opacitySlider?.value = Float(alpha)
- self.opacitySliderView?.startLabel?.text = "\(Int(((self.opacitySliderView?.opacitySlider?.value ?? 0) / 1) * 100))%"
- updatePreferredContentSizeWithTraitCollection(traitCollection: traitCollection)
- }
- }
|