Is it possible create a collision effect with UIImageView without SpriteKit? SWIFT - animation

I want to animate UIImageView's falling from the top side of the Phone and when they touch the lower side they should jump up also when they touch each other after that they should move to someplace. I know that this is possible with SpriteKit (collision detection) but is it also possible without using SpriteKit(something like UIKit)?

Related

How magnify scale of items on touch in swift

I am new to iOS development. I'm trying to create an effect like the following figure shows. There is a list of items in a view, When user touch the view, a portion of the view is scaled from the touch center (but the top is aligned). When touch moves, the magnification effect moves as well with a smooth animation.
Look forward to any kind of help. Thanks in advance.

Animate UIView as flipboard in iOS

I tried to use MPFoldTransition for my UIView animation. But I want it like flipboard. That is, it should be animated as per the user touch.
Please help me that how can I achieve it. Also, is there any other library for UIView animation like flipboard.
If you want to use a library for this flip, MPFlipViewController uses MPFoldTransition and works with a pan gesture.
Also, take a look at https://github.com/ITechRoof/ITRFlipper
If you want to build this yourself and have a true flip like Flipboard (where it flips in the middle, with appropriate shadows), taking a snapshot of the view and using a simple matrix transform can do the trick. I'm not going to go into all the details as I could talk for hours about animation timing and shadows.

Vertical NSLevelIndicator OSX

I wonder if there is a way of creating/modifying a NSLevelIndicator object so it can be positioned vertically, i.e. display discrete levels from bottom up, not from left to right, so it can be also used as element of interface-building library in Xcode?
There are lots of examples of such level displays in Apple and non-Apple OSX applications, and quite a few reasons why such an object should exist, yet how to create such an object for some reason (from what I can see in developer forums) seems either not worth asking or a "best kept secret".
Is there a template code which can be modified to into an object of such properties?
I haven't even faintest idea if such an object should really be written from scratch? Mission impossible?
Thanks in advance!
Try using
[NSView setFrameRotation:90];
it's sketchy but easier than a custom view
Edit: Alternatively try
[levelView setFrameCenterRotation:90];
SetFrameRotation:90 rotated it around the bottom left axis for me so it ended up being clipped. This one rotates it around the centre so you should be able to see it. I just made a quick swift playground showcasing it: http://cl.ly/WsL8/Vertical%20LevelIndicatorView.playground.zip
Edit again: If you're still stuck, I made a sample project with a vertical level indicator in objective-c: http://cl.ly/WrdH/levelindicator.zip
Swift 5.5.1 on macOS 11.6
myLevelIndicator.frameRotation = 90
If you need to reposition the indicator to fit within the view, realize the center of rotation is the origin of the level indicator.
So, to set the rotated level indicator 20px in from the left of the view, compute that for the new frame origin of the level indicator, not forgetting to adjust for the indicators height when it is horizontal because the original height will affect the final position when rotated.
myLevelIndicator.frame.origin = CGPoint(x: self.view.frame.minX+20+myLevelIndicator.frame.height, y: myLevelIndicator.frame.minY)
Of course, this can be avoided by placing the control in the correct position to allow for rotation within IB if that works for you. Some may not be using IB and creating these controls programmatically.

How can I draw something on top of AVPlayer video in Cocoa?

In my app I want to be able to draw rectangles on top of the playing video. I already implemented the drawing canvas which is a NSView, and I have a player implemented as well.
However, when I place my drawing canvas on top of my player view, player view is still showing up on top.
I was thinking that my drawing canvas wasn't on top of the player view, but it is. When I change the size of the window, I can see that on the area of the window that is not covered by the video I can draw. However, magically my drawing is not showing up on top of the playing video.
I really don't know where to find the problem.
Any help is highly appreciated!
i also had a problem where one NSView that i add to a superView was layer backed and the last NSView wasn't, and always the layer backed NSView would be on top, so i'd recommend you to enable the layer for any NSView that would come on top of the AVPlayer,
[yourCanvasView setWantsLayer : YES];
...
i think this would do the job,
There's a solution for iOS, as answered here, and it works in OS X too (I tested on OS X 10.10.2).
Basically, set the zPosition of the view you want on top:
topView.layer.zPosition = 1;

NSWindow Content Border messing with CALayer's geometry

I have an NSWindow with a 32px bottom content border. Inside the window's view, I have two custom subviews. Each of them are layer backed, and I'm tracking the mouse with an NSTrackingArea. Part of what I'm doing is some mouseOver effects with CoreAnimation. This is not a problem in general, but I noticed something kind of strange and wondered if anyone knows why this is happening.
When setting up the trackingArea and mouseOver method, I hitTest the root layer and log the layer's name so I can see if the geometry of the various sublayers hold water when I resize the window. Internally, they seem (and look) fine. Visually, they are in the right place, but when I move the mouse, I notice that the though the mouse is physically over a layer, hitTest is returning whatever layer is 32 px above it. However, if I remove the content border, it works as you would expect and the correct layer is returned.
I obviously need the content border, so I have a very simple workaround which involves offsetting the hitTest point by 32px. This works fine, but it just seems weird that the presence of a content border seems to skewing the co-ordinate system of these subviews. Does anyone know why this could be happening?
NSEvent returns mouse locations relative to the window's coordinate system, not the targeted view's. You probably need to call convertRect:fromView: to get the correct coordinates.

Resources