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, 2022 in IOS by Soham
• 9,710 points
913 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, 2022 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, 2022 in IOS by Soham
• 9,710 points
737 views
0 votes
0 answers

How to access and read a file on a USB drive from IOS? (Connected via OTG cable to iPhone)

Can I access a text file on ...READ MORE

Nov 7, 2022 in IOS by Soham
• 9,710 points
580 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, 2022 in IOS by Aditya
• 7,680 points
4,541 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, 2022 in IOS by Soham
• 9,710 points
1,557 views
0 votes
0 answers

Launch an app from within another (iPhone)

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

Sep 28, 2022 in IOS by Soham
• 9,710 points
441 views
0 votes
0 answers

Merge PDF files on iOS

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

Nov 10, 2022 in Mobile Development by gaurav
• 23,260 points
618 views
0 votes
0 answers

iPhone system font

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

May 16, 2022 in Others by Kichu
• 19,040 points
501 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, 2022 in Others by Aditya
• 7,680 points
504 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, 2022 in IOS by Rahul
• 9,680 points
651 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, 2022 in IOS by Rahul
• 9,680 points
2,130 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