UIImageView内でユーザーが触れる場所のみを表示する 'Selected Box'グラフィックスの境界を設定しようとする多くの組み合わせを行っています。それはまだスーパービューがシステムUIImageViewsの座標境界を別のUIImageViewに使用する
class ViewController: UIViewController {
@IBOutlet weak var selectedBox: UIImageView!
@IBOutlet weak var sodukoGrid: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
selectedBox.hidden = true
selectedBox.frame.origin.x = sodukoGrid.bounds.minX
selectedBox.frame.origin.y = sodukoGrid.bounds.minY
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("tapAction:"))
self.sodukoGrid.userInteractionEnabled = true
self.sodukoGrid.addGestureRecognizer(tapGestureRecognizer)
}
func tapAction(sender: UITapGestureRecognizer) {
let touchPoint = sender.locationInView(self.sodukoGrid)
print(touchPoint)
selectedBox.center.x = CGFloat(touchPoint.x)
selectedBox.center.y = CGFloat(touchPoint.y)
}
Image showing the selected box graphic still sticking to the superviews bounds