• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to customize View to combine UITextView and UITextField?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to customize View to combine UITextView and UITextField?


  • Subject: How to customize View to combine UITextView and UITextField?
  • From: 张志明 <email@hidden>
  • Date: Sat, 19 Jul 2008 22:27:29 +0800 (CST)

 I'd like to include one UITextView and one TextField in the headsection of tableView. So I subclass UIView and tried to override the drawRect method. I read the reference guide of UITextField drawRect method, "You should not call this method directly." How can I include a UiTextField in my customized UIView?
when I called method drawInRect, it broke, please kindly find my code as follows.
And I found UITextView has no drawTextInRect, I called drawRect instead, but it did not work and I had no output.


- (void)drawRect:(CGRect)rect {
 // Drawing code
    UIImage *myImage = [UIImage imageNamed:@"zzm_o.png"];
 [myImage drawInRect:CGRectMake(0, 0, 80, 60)];
 UILabel *labelTest = [[[UILabel alloc] initWithFrame: CGRectMake(0, 50, 200, 20)] autorelease];
 labelTest.font = [UIFont systemFontOfSize: 15.0];
 labelTest.textAlignment = UITextAlignmentLeft;
 labelTest.textColor = [UIColor blueColor];
 labelTest.backgroundColor = [UIColor whiteColor];
 labelTest.text = @"Test Label";
 //[labelTest drawTextInRect:CGRectMake(0, 50, 80, 30)];

 /*UITextField *aTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 50, 200, 20)];
    aTextField.borderStyle = UITextBorderStyleBezel;
    aTextField.textColor = [UIColor whiteColor];
 aTextField.font = [UIFont systemFontOfSize:15.0];
    aTextField.placeholder = @"<enter email>";
    aTextField.backgroundColor = [UIColor blackColor];

 aTextField.keyboardType = UIKeyboardTypeDefault;
 aTextField.returnKeyType = UIReturnKeyDone;
 aTextField.delegate =self;


 aTextField.clearButtonMode = UITextFieldViewModeWhileEditing; // has a clear 'x' button to the right
 [aTextField drawTextInRect: CGRectMake(0, 50, 80, 30)];*/

 UITextView *commentBodytextView = [[[UITextView alloc] initWithFrame:CGRectMake( 0, 0, 200, 100)] autorelease];
 commentBodytextView.textColor = [UIColor whiteColor];
 commentBodytextView.font = [UIFont systemFontOfSize:15.0];
 commentBodytextView.backgroundColor = [UIColor blackColor];
 //commentBodytextView.delegate = self;
 //textView.backgroundColor = [UIColor whiteColor];
 commentBodytextView.scrollEnabled = YES;
 //commentBodytextView.opaque = YES;
 //commentBodytextView.alpha = 1.0;

 commentBodytextView.text = @"Now is the time for all good people to come to serve their country.\n\n\nNow is the time for all good people to come to serve their country.";

 commentBodytextView.editable = NO;
 [commentBodytextView drawRect:CGRectMake( 0, 0, 200, 100)];


 UIFont *font = [UIFont boldSystemFontOfSize:20];
 [[UIColor whiteColor] set];
 NSString *string = @"Molinker Test!";
 [string drawAtPoint:CGPointMake(0, 65) withFont:font];



}




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • [Moderator] Re: How to customize View to combine UITextView and UITextField?
      • From: Scott Anguish <email@hidden>
    • Re: How to customize View to combine UITextView and UITextField?
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: substitute class at runtime?
  • Next by Date: Re: How to customize View to combine UITextView and UITextField?
  • Previous by thread: Re: How to get cursor text from a Mac window
  • Next by thread: Re: How to customize View to combine UITextView and UITextField?
  • Index(es):
    • Date
    • Thread