MijickCamera/Sources/Internal/UI/Camera View/CameraView+FocusIndicator.swift

34 lines
1.1 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// CameraView+FocusIndicator.swift of MijickCamera
//
// Created by Tomasz Kurylik. Sending from Kraków!
// - Mail: tomasz.kurylik@mijick.com
// - GitHub: https://github.com/FulcrumOne
// - Medium: https://medium.com/@mijick
//
// Copyright ©2024 Mijick. All rights reserved.
import SwiftUI
@MainActor class CameraFocusIndicatorView {
var image: UIImage = .init(resource: .mijickIconCrosshair)
var tintColor: UIColor = .init(resource: .mijickBackgroundYellow)
var size: CGFloat = 96
}
// MARK: Create
extension CameraFocusIndicatorView {
func create(at touchPoint: CGPoint) -> UIImageView {
let focusIndicator = UIImageView(image: image)
focusIndicator.contentMode = .scaleAspectFit
focusIndicator.tintColor = tintColor
focusIndicator.frame.size = .init(width: size, height: size)
focusIndicator.frame.origin.x = touchPoint.x - size / 2
focusIndicator.frame.origin.y = touchPoint.y - size / 2
focusIndicator.transform = .init(scaleX: 0, y: 0)
focusIndicator.tag = .focusIndicatorTag
return focusIndicator
}
}