-2

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:

enter image description here

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.

Community
  • 1
  • 1
ƒernando Valle
  • 3,634
  • 6
  • 36
  • 58

4 Answers4

1

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...

ares777
  • 3,590
  • 1
  • 22
  • 23
1

Please have a look of below link hope this will helpful for you. Link : Here is Answer to set shadow in your view.

Community
  • 1
  • 1
Vinod Pandey
  • 183
  • 4
1

I finally solved my question inspired by iShowCase library I did this simple class and Upload to github.

https://github.com/tato469/FVEasyShowCase

ƒernando Valle
  • 3,634
  • 6
  • 36
  • 58
0

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 ^_^