0

I need your help with solving this problem. My UIImage is allowed to be moved around the screen using PanGesture and it also has TapGesture to rotate with trasform

.transform.rotated(by: CGFloat(M_PI_4))

After user is done with positioning and rotating, he clicks the UIbutton to show a four dots in corners of the Image

//dotcode
    let dotSize = 20
        let firstDotView = UIView()

        firstDotView.frame = CGRect(x: 0, y: 0, width: dotSize, height: dotSize)
        firstDotView.backgroundColor = UIColor.black
        firstDotView.layer.cornerRadius = 10

        view.addSubview(firstDotView)

1: dots like that, don't have any connection with green space

Dots always show in the corner

Lukas
  • 1
  • 4
  • That's a spec. What's the _question_? – matt Apr 18 '19 at 20:08
  • has to be calculated on base of the arc respectively radius, as the image-center is unimportant for the location I think. So you should add the code for the other image-elements to your question. – David Apr 18 '19 at 20:11
  • doesn't have to be that specific location, can be even corner, but if I start in up right corner and then make a rotation by 90 degrees, dot should appear in down right corner after clicking button – Lukas Apr 18 '19 at 20:15
  • Has UIImage a canvas? then just turn the whole canvas and the coords can stay the same. – David Apr 18 '19 at 20:18
  • might be, but how to do placing? right now I am doing something like DotView.center.x = imageView.center.x + 50.0 DotView.center.y = imageView.center.y + 50.0 which is not really doing my job, as it seems like placing randomly all the time, every image location it appears differently – Lukas Apr 18 '19 at 20:38
  • anyway, let's suppose that image is just regular rectangle but it has specific point I want to always place my dot no matter how rotated or moved the rectangle is, it always goes with it – Lukas Apr 18 '19 at 20:42
  • Are you able to add `firstDotView` as a subview to the image view instead of the main view? –  Apr 18 '19 at 21:51
  • is it even possible? scrolling through the internet with no luck, only some "non official" way by changing image view into view like: https://stackoverflow.com/questions/2415561/apple-interface-builder-adding-subview-to-uiimageview ... right now my image view(that arc) is subview of other view, which is also location where I can move it around. By starting the app, imageview always starts in exact middle of the view. Not sure if it helps somehow.... – Lukas Apr 19 '19 at 06:28
  • revisited my question a bit, now let's show dots in the corners of ImageView, might be easier. Found this: (BladeBunny answer) https://stackoverflow.com/questions/19523487/find-frame-coordinates-after-uiview-transform-is-applied-cgaffinetransform but for me is not clear how to implement to show a dot in those corners – Lukas Apr 23 '19 at 13:25

0 Answers0