How is a rounded rect view with transparency done on iphone

0 votes
When doing a time-consuming action, many apps display a transparent view with rounded sides and an activityIndicator.

How is this rounding carried out, and can it be accomplished using only Interface Builder (because I would like to apply something similar in many places)? Or should I employ an imageview with a stretchable or rounded rect? Do I have to create the background from scratch?

Though it lacks rounded corners and the transparency appears to apply to all subviews (I don't want the text and activity indicator to be translucent, even though I set the alphaValue on zero), I have so far been able to create a basic view with transparency that is similar.
Sep 21 in IOS by Soham
• 9,330 points
18 views

1 answer to this question.

0 votes
view.layer.cornerRadius = radius;

The difficult technique is to develop your own UIView subclass using the drawRect: method, which was necessary in the initial iPhone SDK.

 CGContextRef context = UIGraphicsGetCurrentContext();
 CGContextSetRGBFillColor(context, 0,0,0,0.75);

 CGContextMoveToPoint(context, rect.origin.x, rect.origin.y + radius);
 CGContextAddLineToPoint(context, rect.origin.x, rect.origin.y + rect.size.height - radius);
 CGContextAddArc(context, rect.origin.x + radius, rect.origin.y + rect.size.height - radius, 
                radius, M_PI, M_PI / 2, 1); //STS fixed
 CGContextAddLineToPoint(context, rect.origin.x + rect.size.width - radius, 
                        rect.origin.y + rect.size.height);
 CGContextAddArc(context, rect.origin.x + rect.size.width - radius, 
                rect.origin.y + rect.size.height - radius, radius, M_PI / 2, 0.0f, 1);
 CGContextAddLineToPoint(context, rect.origin.x + rect.size.width, rect.origin.y + radius);
 CGContextAddArc(context, rect.origin.x + rect.size.width - radius, rect.origin.y + radius, 
                radius, 0.0f, -M_PI / 2, 1);
 CGContextAddLineToPoint(context, rect.origin.x + radius, rect.origin.y);
 CGContextAddArc(context, rect.origin.x + radius, rect.origin.y + radius, radius, 
                -M_PI / 2, M_PI, 1);

 CGContextFillPath(context);

Note: The rect in this code should be taken from [self limits] (or wherever you want it to be), since the rect supplied to the drawRect: method will not make sense.

answered Sep 22 by Rahul
• 9,240 points

Related Questions In IOS

0 votes
0 answers

How to connect iphone to a local server running on mac?

I am running a django server at ...READ MORE

Sep 22 in IOS by Soham
• 9,330 points
10 views
0 votes
1 answer

Is it possible to run .APK/Android apps on iPad/iPhone devices?

It is not possible to run Android ...READ MORE

answered Sep 20 in IOS by Aditya
• 7,660 points
17 views
0 votes
1 answer

HTTP live streaming server on iPhone

If you don't encode the raw h264 ...READ MORE

answered Sep 20 in IOS by Aditya
• 7,660 points
19 views
0 votes
1 answer

Is there a way to generate high resolution PNGs of iOS emoji?

The glyphs for the "Apple Color Emoji" ...READ MORE

answered Sep 20 in IOS by Aditya
• 7,660 points
21 views
0 votes
0 answers

Launch an app from within another (iPhone)

Is it possible to open any iPhone ...READ MORE

5 days ago in IOS by Soham
• 9,330 points
9 views
0 votes
0 answers

iPhone system font

What is the name of the default ...READ MORE

May 16 in Others by Kichu
• 19,040 points
28 views
0 votes
1 answer

How to get landmarks from current location using google map in iphone?

You can achieve this by saving several ...READ MORE

answered Sep 20 in Others by Aditya
• 7,660 points
18 views
0 votes
1 answer

iPhone system font

The iPhone system interface uses Helvetica or ...READ MORE

answered Sep 20 in Others by Aditya
• 7,660 points
19 views
0 votes
1 answer

Is there a way to to check if a picture was taken on that iPhone?

Actually, the model and manufacturer information is ...READ MORE

answered Sep 22 in IOS by Rahul
• 9,240 points
16 views
0 votes
1 answer

How to build a font generator in iOS Swift and allowing pasting to clipboard

On your iPhone, you cannot copy and ...READ MORE

answered Sep 22 in IOS by Rahul
• 9,240 points
23 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP