How to create a UIView in circle Shape - uiview

I want to make a UIImage in a circle shape like this and many other shapes and save to photo album can any one suggest me how to do this?

Related

Draw on face of SCNNode

I am experimenting with ARKit and SceneKit and have been able to place boxes or custom shapes using UIBezierPath. What I’d like to do next is draw text and place images on the surface of these shapes. I’ve tried adding an image to the material property but this just fills the shape with an image. I’d like to have control over the size and position of the image / text relative to the shape. Is this possible?
You can do so by creating a new node for your text or image, and add it as a child node of your existing SCNNode (addChildNode). You can then position it as needed relative to your parent node, much as you have already done with your SCNNode.
For text you can make your SCNNode from an SCNText, or render the text into a bitmap and use it as a texture material of an SCNPlane.

Creating an irregular UIButton in Swift where transparent parts are not tappable

I am making a pie chart where each sector is a separate button with a background image, but UIButton has a rectangular shape and all the buttons overlap. Is there a way to make a UIButton the exact shape of an irregular image (in Swift) so this does not happen?
Any help would be appreciated
You can use UIBezierPath or CGPath to define your pie chart sections and use their containsPoint: or CGPathContainsPoint to detect touch
As I'm concerned, may be the CAShapeLayer is better way to achieve the pie chart. By doing that, you can use
[layer hitTest:]
method to deal with the touch action.

How to create a non-rectangular UIImageView

I'm trying to make a ViewController that presents info from a webpage like this:
However, I'm confused on one thing. How did they get the imageView to display an image that's cut off at the corner, i.e. not rectangular? Do you think they created that player card in Photoshop and used it as the background for the imageView image, or did they create it programmatically?
I wonder because the image is behind the picture of the bear, so I imagine if they created the background in Photoshop, how would they get the image behind the bear head? They can't have just created the card with the player's picture as part of it, then loaded the whole image because if they traded the player, because I'm sure they pull the player info and picture from the web so they can have a card for all players, even if they trade or acquire a new player mid-season, without having to update the app (and add the finished image to images.xcassets).
This can be composed from two CALayers at runtime. Put the picture on the bottom layer; the picture can come from anywhere - the web, the bundle, etc. the image source could be dynamic.
Put another CALayer on top, with the frame rendered with opaque colors, and a transparent cut-out for the picture in the middle:
There are a bunch of ways to do this. A simple and flexible way to do it is to create a CAShapeLayer that's the same size as the image view, with it's origin at 0,0, and add it as the UIImageView's layer's mask.
You'd create a filled UIBezierPath that maps out the part of the image you want to show, and install the bezier path's CGPath into the mask layer's path property.
The result would be that the image view is cropped so that only the part inside the shape is drawn.

how to create a custom UIImage shape in Objective-C

I created an app where your goal is to dodge rocks, but when the character hits the frame of the UIImage of one of the rock obstacles(it is an irregular shaped rock) it gets destroyed. This creates the problem of dying when you hit the UIImage frame of the image and not the actual rock. Is there a way to make the UIImage not have a square shaped frame? Or do you know of any other way to solve this problem?

UIimageview fit to round shape

I have an UIImageview that contains a circle (The obstacle) and then another UIImageview that contains another image (my character). When my circle hits my character the game ends.
My problem occurs when the game ends on the character touching the UIImageview box that my circle is within, rather than the circle inside the UIImageview box.
The solutions I can think of are:
Make the UIImageview rounded to fit my circle.
Somehow detect a collision between my characters pixels and the circles pixels rather than the UIImageviews.
Help and ideas would be really appreciated. I am a beginner with xcode.
Thanks!
Couple of different techniques:
1)UIView#layer.cornerRadius - Super simple to implement, just set that one property. But really bad for scrolling elements like table views.
2)UIImageView as a mask - Also easy to implement. Basically make a square image with a transparent circle in the middle and slap it on top of your view with a new UIImageView. If your circle design has some reflections or styling, this might make your life easier.
3)Custom drawing - Make a UIView subclass and override drawRect to draw your image and clip it to a circular path.
Hope that helps!
EDIT:
You can read this answers.
1)Fill an UIBezierPath with a UIImage
2)iOS: Inverse UIBezierPath (bezierPathWithOvalInRect)
3)How to mask a square image into an image with round corners in the iPhone SDK?

Resources