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

  • SEARCH
  • Home
  • 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 8960631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:42:09+00:00 2026-06-15T15:42:09+00:00

I must custom UITextField like the image above, so i try to write my

  • 0

enter image description here

I must custom UITextField like the image above, so i try to write my custom class extend UITextField class.
But my problem is: stroke shadow outline of rect, and set white background for textfield inside
my custom code is:

- (void)drawRect:(CGRect)rect
 {
  // Drawing code
     self.autocorrectionType = UITextAutocorrectionTypeNo;
     self.autocapitalizationType = UITextAutocapitalizationTypeNone;
     CALayer *layer = self.layer;
     layer.cornerRadius = 15.0;
     layer.masksToBounds = YES;
     layer.borderWidth = 1.0;
     layer.borderColor = [[UIColor colorWithRed:0 green:0 blue:0 alpha:1] CGColor];
     [layer setShadowColor: [[UIColor blackColor] CGColor]];
     [layer setShadowOpacity:1];
     [layer setShadowOffset: CGSizeMake(2.0, 2.0)];
     [self setClipsToBounds:NO];
     [self setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
     [self setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
 }
  - (CGRect)textRectForBounds:(CGRect)bounds {
          return CGRectMake(bounds.origin.x + 20, bounds.origin.y + 8,
                  bounds.size.width - 40, bounds.size.height - 16);
 }
 - (CGRect)editingRectForBounds:(CGRect)bounds {
          return [self textRectForBounds:bounds];
 }

So my question is: what code i’m missing(here is set white background inside, set outline shadow for border) thanks for your helps!

  • 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-15T15:42:10+00:00Added an answer on June 15, 2026 at 3:42 pm

    Have you try this first?
    self.textField.background = myUIImage;
    self.textField.borderStyle = UITextBorderStyleNone;

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

Sidebar

Related Questions

There must be a simple solution to this problem but for the love of
I am suffering the same problem as here UITextField's custom font changes while in
I'm developping a log4net wrapper and I must inherit a custom class from log4net.Core.LogImpl
I must be missing something basic here but while developing a custom jQuery widget,
I feel like I'm missing something obvious. I've got a custom segue class. It
I have custom components which must adjust their text content based on space constraints.
I'm writing a custom dice rolling parser (snicker if you must) in python. Basically,
I'm trying to create a complex custom NSControl that must be able to send
I extended JDialog to create a custom dialog where the user must fill some
Must be missing something really obvious here but how do you change the size

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.