Popup ViewControllers
ViewControllerModal overlay components: TTBasePopupViewController (dimmed overlay, tap-to-dismiss), TTDismissView (drag handle for sheets), and TTBasePresentationController / CoverVerticalPresentationController (custom presentation controls).
| Class | Description |
|---|---|
TTBasePopupViewController | Modal VC with 85% dark overlay, fade animation, tap-to-dismiss |
TTDismissView | Drag handle indicator bar (bottom sheet style) |
TTBasePresentationController | Base custom UIPresentationController |
CoverVerticalPresentationController | Cover-from-bottom slide-up sheet |
CoverVerticalViewController | VC preset for cover-vertical presentation |
📦 TTBasePopupViewController
// Subclass for your custom popup
class ConfirmationPopup: TTBasePopupViewController {
private let panel = TTBaseShadowPanelView()
private let titleLabel = TTBaseUILabel(withType: .TITLE, text: "Delete Item?", align: .center)
private let cancelBtn = TTBaseUIButton(textString: "Cancel", type: .DEFAULT, isSetSize: false)
private let confirmBtn = TTBaseUIButton(textString: "Delete", type: .WARRING, isSetSize: false)
var onConfirm: (() -> Void)?
init() {
super.init(isAllowTouchPanel: true) // tap outside to dismiss
}
override func viewDidLoad() {
super.viewDidLoad()
setupPanel()
}
func setupPanel() {
view.addSubview(panel)
panel.panelShadowView.addSubview(titleLabel)
// ... add buttons
confirmBtn.onTouchHandler = { [weak self] _ in
self?.dismiss(animated: true)
self?.onConfirm?()
}
}
}
// Present it
let popup = ConfirmationPopup()
popup.onConfirm = { self.viewModel.deleteItem() }
present(popup, animated: true)
↕️ TTDismissView (drag handle)
// Add drag handle to bottom sheet
class BottomSheet: TTBasePopupViewController {
private let dismissHandle = TTDismissView()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(dismissHandle)
dismissHandle.setLeadingAnchor(constant: 0)
.setTrailingAnchor(constant: 0)
.setTopAnchor(constant: 0)
.setHeightAnchor(constant: 24)
// Add pan gesture for swipe-down dismiss
let pan = UIPanGestureRecognizer(target: self, action: #selector(handlePan))
dismissHandle.addGestureRecognizer(pan)
}
}
📖 TTBasePopupViewController Properties
| Member | Type | Description |
|---|---|---|
init(isAllowTouchPanel:) | Init | Allow/block tap-outside-to-dismiss |
panelTouchView | TTBaseUIView | Transparent touchable dimming area |
navType | .NO_VIEW | No navigation bar by default |
modalPresentationStyle | .overCurrentContext | Shows over current screen |
modalTransitionStyle | .crossDissolve | Fade in/out animation |
Pro Tip: Set
isAllowTouchPanel: false for critical popups (e.g., mandatory update, payment confirmation) where you want to force the user to interact with buttons before dismissing.