Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:17:55+00:00 2026-06-06T06:17:55+00:00

I have an iPhone application and I need to implement the following method: +(UITextView

  • 0

I have an iPhone application and I need to implement the following method:

+(UITextView *)textView:(UITextView *) withCuttedRect:(CGRect)r

This method must cut (fill with [UIColor clearColor]) the rect r from UITextView and return UITextView object.

The user will see the view behind UITextView from the cutted holes.

How can it be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:17:57+00:00Added an answer on June 6, 2026 at 6:17 am

    When you would have something like:

     +(UITextView *)textView:(UITextView *)textView withCuttedRect:(CGRect)r {
    }
    

    you actually can simply access the textview’s layer from core animation with

     textView.layer
    

    What you then can to is set a mask for clipping. These masks work the following way: you generally draw a black shape, and that stays the same, the rest will be clipped (ok, you actually can also do some things on the alpha channel but roughly that is it).

    So you need a black rectangle as a mask, with a rectangle within the rectangle which is free. for that you can approximately do

     CAShapeLayer *mask = [[CAShapeLayer alloc] init];
     mask.frame = self.textView.layer.bounds;
     CGRect biggerRect = CGRectMake(mask.frame.origin.x, mask.frame.origin.y, mask.frame.size.width, mask.frame.size.height);
     CGRect smallerRect = CGRectMake(50.0f, 50.0f, 10.0f, 10.0f);
    
     UIBezierPath *maskPath = [UIBezierPath bezierPath];
    [maskPath moveToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMaxY(biggerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMaxY(biggerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(biggerRect), CGRectGetMinY(biggerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMinX(biggerRect), CGRectGetMinY(biggerRect))];
    
    [maskPath moveToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMaxY(smallerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMaxY(smallerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMaxX(smallerRect), CGRectGetMinY(smallerRect))];
    [maskPath addLineToPoint:CGPointMake(CGRectGetMinX(smallerRect), CGRectGetMinY(smallerRect))];
    
     mask.path = maskPath.CGPath;
    [mask setFillRule:kCAFillRuleEvenOdd];
     mask.fillColor = [[UIColor blackColor] CGColor];
     self.textView.layer.mask = mask;
    

    The code above is also disused by Crop a CAShapeLayer retrieving the external path

    The idea why that filling works that way is nicely explained in Quartz 2D Programming Guide in the section “Filling a Path”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iPhone application which in which I want to perform a method
I have an iPhone application where i need to find out the current location(in
I need to implement cover flow functionality to our iPhone application. I tried to
i am developing an application in iPhone, where i need to implement my 5
I need to have a search bar control in my iPhone application, but I'd
I need to check my iPhone application memory leaks. I went following link and
I need to know as to how to implement oAuth in an iphone application.
I have implement an iPhone application in jQuery mobile and Phone Gap Using list
To implement as above in an PhoneGap iPhone application I have used nested list
I have an iphone application which has about 4 tabs. How do I force

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.