I want to achieve this effect on UIView. I have tried with UIBezierPath but no success so far.
Below is sample image.
Check below answer,
import #import <QuartzCore/QuartzCore.h>
and write code
view.layer.cornerRadius = 5;
view.layer.masksToBounds = true;
Another different approach is
[view.layer setCornerRadius:25.0f];
[view.layer setMasksToBounds:YES];
I'm not sure if this can help but, if you select the item of interest from the storyboard, select the following icon and in the box type layer.cornerRadius and change boolean to string and then type whatever multiplier you want.
I want to create a black UIView with transparent circles.
I think about create one view (with black color and transparence 50%), and add multiple circles inside of it, but I don't know how to set the transparence for each. I know how to create a circle View (an example: how to draw a custom uiview that is just a circle iphone-app).
I want to do is something like iShowcase library but with multiple dots:
Any clue? thanks.
SOLVED
I took a look to the code of iShowcase library and I solved my probblem. now, I am working in a library based in iShowcase library.
I will post here when I finish it.
Please have a look of below link hope this will helpful for you.
Link : Here is Answer to set shadow in your view.
Use alpha for your circleView. As in your link example,then add as subviews in yourmainview:
UIView *circleView = [[UIView alloc] initWithFrame:CGRectMake(10,20,100,100)];
circleView.alpha = 0.5;
circleView.layer.cornerRadius = 50;
circleView.backgroundColor = [UIColor whiteColor];
[yourmainview addSubview: circleView];
Btw in your picture I think white circles have 100% alpha. You can use individual alpha for each circleView, or use a randomizer :)
As for updated example why don't you add more buttons and showcase in your h file, synthesize them and use multiple instances .... showcase setupShowcaseForTarget:btn_custom_1 title:#"title" details:#"other"]; ? I think you should modify main classes, becouse what you want are different containerView for multiple views [circles].
Using modifyed iShowcase.m [- (void) calculateRegion], and different views as containers, I was able to make something like: http://tinypic.com/view.php?pic=2iwao6&s=8#.VLPTRqYsRE8 So the answer is: use custom views for multiple showcase [ex [showcase2 setContainerView:self.view2];], then custom frame for each showcase [ showcase2.frame = CGRectMake(0,0,100,100);] I don;t habe time to fine tuning the example, but yes, you can achieve desired result...
I finally solved my question inspired by iShowCase library I did this simple class and Upload to github.
https://github.com/tato469/FVEasyShowCase
Simplest what you can do is to have your main view (black 50% transparant) and add shapes to the mask layer of that.
So basically:
//Set up your main view.
UIView* mainView = [UIView new];
mainView.backgroundColor = [UIColor blackColor];
mainView.alpha = 0.5;
UIView* circle1 = [YourCircleClassHere new];
UIView* circle2 = [YourCircleClassHere new];
UIView* circle3 = [YourCircleClassHere new];
UIView* container = [UIView new];
[UIView addSubview:circle1];
[UIView addSubview:circle2];
[UIView addSubview:circle3];
//Make a new layer to put images in to mask out
CALayer* maskLayer = [CALAyer layer];
//Assign the mask view to the contents layer.
maskLayer.contents = (id)container;
//This will set the mask layer to the top left corner.
maskLayer.frame = CGRectMake(0,0,container.frame.size.width,container.frame.size.height);
//Lastly you assign the layer to the mask layer of the main view.
mainView.layer.mask = maskLayer;
//Applies basically the same as clipToBounds, but a bit reversed..
mainView.layer.mask = true/false;
On a sidenote:
I achieved this with images "contents = (id) [UIImage CGImage]", but I'm sure it should work with UIViews as well.
Also mind some mistakes, since I just wrote this from my mind, also I didn't test this out.. So keep me updated if it works/!works ^_^
I've got a problem with rotating NSView
Let's say I have a NSImageView like this:
sampleImage = [[NSImageView alloc] initWithFrame:CGRectMake(50,50,50,50)];
sampleImage.image = [NSImage imageNamed:#"image"];
[self.view addSubview:sampleImage];
That looks like this:
Now I want to rotate this image by 60 degrees. I've tried several solutions to this problem, but none of them gave me satisfactory results.
I've tried with:
[sampleImage rotateByAngle:60];
results looks like this:
[sampleImage setFrameCenterRotation:60];
results:
Using AffineTransform and layers (I've set up wantsLayer = YES for superviews as well) doesn't rotate image at all:
sampleImage.wantsLayer = YES;
sampleImage.layer.affineTransform = CGAffineTransformMakeRotation(60);
rotating with CATransform3DMakeRotation doesn't work as well:
sampleImage.transform = CATransform3DMakeRotation(GLKMathRadiansToDegrees((float) -marker.rotation), 0, 0, 1.0);
What is proper method to rotate images in OSX ? On IOS it's piece a cake: applying proper affineTransform work's like a charm - it looks like Cocoa on OSX isn't so willing to rotate views.
I'm shrinking a UIImageView but it's looks horrible and aliased.
I've tried changing the 'minifactionFilter' property but I don't see any effects.
Is there a special way to implement this? There's not much info in apple's docs.
self.imageView.layer.minificationFilter = kCAFilterLinear;
self.imageView.layer.cornerRadius = 9.0;
self.imageView.layer.masksToBounds = YES;
I know the layer properties are working as I can see the round corners but interpolation always looks the same.
kCAFilterNearest
kCAFilterLinear
kCAFilterTriLinear
I've seen lots of snippets that either: are too complicated for something as simple as a drop shadow, requiring subclassing UIView and using quartz2d calls, or I can't get them to work.
I just want to do this on a view I'm adding as a subview to another one (the subview is taken from another viewController I'm just allocating - I know that's probably not nice but oh well), no IB or anything. what's the simplest / most accepted way to go about it? would it be different if I want it to work on iOS 4?
It's as easy as importing <QuartzCore/QuartzCore.h> and using a similar snippet as below:
self.viewAboutContainer.layer.shadowColor = [[UIColor blackColor] CGColor];
self.viewAboutContainer.layer.shadowOpacity = 0.7;
self.viewAboutContainer.layer.shadowRadius = 4.0;
self.viewAboutContainer.layer.shadowOffset = CGSizeMake(5.0f, 5.0f);
self.viewAboutContainer.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.viewAboutContainer.bounds].CGPath;