NetNewsWire/iOS/MasterTimeline/MasterTimelineTitleView.swift

57 lines
1.4 KiB
Swift
Raw Normal View History

2019-09-22 00:59:58 +02:00
//
// MasterFeedTitleView.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 9/21/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
class MasterTimelineTitleView: UIView {
@IBOutlet weak var iconView: IconView!
2019-09-22 00:59:58 +02:00
@IBOutlet weak var label: UILabel!
2019-10-01 03:01:02 +02:00
@IBOutlet weak var unreadCountView: MasterTimelineUnreadCountView!
@available(iOS 13.4, *)
private lazy var pointerInteraction: UIPointerInteraction = {
UIPointerInteraction(delegate: self)
}()
func buttonize() {
heightAnchor.constraint(equalToConstant: 40.0).isActive = true
accessibilityTraits = .button
if #available(iOS 13.4, *) {
addInteraction(pointerInteraction)
}
}
func debuttonize() {
accessibilityTraits.remove(.button)
if #available(iOS 13.4, *) {
removeInteraction(pointerInteraction)
}
}
}
extension MasterTimelineTitleView: UIPointerInteractionDelegate {
@available(iOS 13.4, *)
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
let params = UIPreviewParameters()
var rect = self.bounds
rect.origin.x = rect.origin.x - 10
rect.size.width = rect.width + 20
let path = UIBezierPath(roundedRect: rect, cornerRadius: 10.0)
params.visiblePath = path
let preview = UITargetedPreview(view: self, parameters: params)
return UIPointerStyle(effect: .automatic(preview), shape: .path(path))
}
2019-09-22 00:59:58 +02:00
}