CAShapeLayer not tapable when above UIScrollView - ios

I have a UIScrollView that has a circular shape and inside it there is a image placed on the screen and above the UIScrollView shape to the right side of it.
I also have a CAShapeLayer that has a circular shape too that is overlapping a little, becouse i want it to look like that.
The problem is my touchesBegan cant detect tap in the overlapping area of the CAShapeLayer.
I want to be able to scroll the image inside UIScrollView while be able to tap the whole area of the CAShapeLayer object with objective c.
Please help me and show me how... i don't know how to do it.. have searched in 4 days.. but i can't find a way.

Related

How can I get the outline of a UIView

Is it possible to get the outline of an UIView as a CGPath? I've taken a look over the UIView and CALayer methods but I couldn't find anything useful.
Edit
Consider the image below. I want the CGPath that follows the border (assuming that outside the border the view is transparent). This is just an example, I need something that would work with any shapes.
A UIView (or NSView in Mac) is a rectangular area by definition. What you see in your Show Notification example is the result of drawing into that view.

iOS swift - how to draw an ellipse with touch event

currently I am trying to port my old windows phone app to iphone. The UI looks like this:
I want to know how to do the following:
Draw a solid ellipse on a specific position, e.g. at position x = 0, y = 0;
The ellipse change its color upon touch;
Touch another position on screen, the ellipse animated to move to the specific position.
I tried several tutorial on how to override drawRect in UIView, but couldn't get it work, can anyone help provide a simple sample?
Thanks a lot!
Edit: Any sample code is highly appreciated.
There aren't much swift code on the internet and samples are not easy to find...
Animating inside a drawRect is never recommended. Why not just put an UIView on the place where you want it and animate the coordinates of that view?
The UIView could be a custom view responding to touch and then triggering the drawRect with a new color.
The parent view where you place these views on can respond to touches and move the ellipse view to the right position.

Guidance - Custom UICollectionView animation

I am looking for guidance with how to approach the following animation scenario.
I have UICollectionView with a custom circular UICollectionViewLayout subclassed layout. There are (circular) images around the perimeter of the circle and a 50% larger (circular) image in the center of the circle.
When the user taps one of the perimeter images, I want the tapped on image to move toward the center (becoming 50% bigger) and sort of "connect with" the center image. I then want the two images to float to the top of the view. (The bottom portion of the view will then be a context of things related to the two joined images).
If this makes sense to anyone, I'd really appreciate a starting point of some kind.
By the way, I'm an old developer but new to iOS and developing in Swift (but can read Objective-C).
Thanks!
I solved this using a visual trick. Of course, I'm sure there's a better way.
When one of the perimeter circles is tapped, I transition to a view controller that immediately creates a duplicate of the center circle and the tapped circle in their former locations, making it appear that the other elements disappeared.
I then simultaneously animate the tapped circle to the center and the center image to the top of the view. I enlarge the tapped circle briefly and then animate it to the top of the view next to the center circle restoring the tapped image's original size.
Not elegant but it works.

iOS Button Custom Image bounds

I have multiple buttons in the shape of an octagon, and they are all right next to each other. Sharing edges. However, when i import these custom images for a button, the bounds of the custom shape is a square. Therefore, part of one of the octagon is overlapping the one right next to this. Not the actual octagon but the transform tool/modifer button bounds. Thus part of the button, though it is hidden, is overlapping another button. How do i modify the button to only take shape to the bounds of the custom shape?
subclass UIButton and override -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event. check if the point is inside your octagon shape and return YES in that case, otherwise NO. Then the buttons will technically still be overlapping but only consume touch events inside your shape.

Best way to draw line between fix CGPoint and moving UIView object's center point

I have a UIView subclass object that animates and therefore changes its position over time as a subview in my UIViewController's view. Actually my moving UIView subclass is just an image of a ball and it's moving as if it was hanging down from my devices screens top border. But to be a real pendulum I'd like to also draw a line between my ball and the CGPoint it hangs down from on top of my screen.
My idea was to just draw a line every time the UIView changes its position. But as the moving is done within an iOS API (I'm just calling something like [myBallView swing]) I can't do this at the same place the movement is happening. I'm actually not animating the view myself.
The only solution I have in my mind to solve my issue is pretty bad: subclassing UIView, adding it as a superview to my moving UIView and adding a line every time drawRect is called. But I'm not even sure drawRect is going to be called there. Either way, there must be a better solution for this.
Does anyone know a good solution to my problem?
Making a custom subclass of UIView as the superview is reasonable.
However, rather than drawing the line yourself, I would suggest implementing +layerClass in your custom view, and making the backing layer a CAShapeLayer.
Then you can create a CGPath in the view's shape layer that is a line, and manipulate the start and end points of the line when your other view's center moves. Shape layers are designed to draw as part of the screen update process, and you could even make the change animate by changing the endpoints of the path with a CABasicAnimation.

Resources