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,670 points
39 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,680 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,670 points
44 views
0 votes
0 answers
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
185 views
0 votes
0 answers

How can I do login with google adsense in an iphone app?

How can I log in to an ...READ MORE

Nov 4 in IOS by Soham
• 9,670 points
107 views
0 votes
0 answers

Launch an app from within another (iPhone)

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

Sep 28 in IOS by Soham
• 9,670 points
47 views
0 votes
0 answers

Merge PDF files on iOS

Is there a way in iOS to ...READ MORE

Nov 10 in Mobile Development by gaurav
• 22,040 points
25 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
51 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
56 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,680 points
37 views
0 votes
1 answer

How to get rid of blank space from iPhone notch on web page

You should be looking for the meta-setting ...READ MORE

answered Nov 8 in IOS by Rahul
• 9,680 points
31 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