开发者

Problem TextField changing into search text

开发者 https://www.devze.com 2023-03-15 14:00 出处:网络
I am creating textfield for my text. when i create its showing me a line attached to my text field. i attached the image to this..

Problem TextField changing into search text

I am creating textfield for my text.

when i create its showing me a line attached to my text field.

i attached the image to this..

My code is

-(void)createTextField{

    if (([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeLeft)||([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeRight)) {
        [text setFrame:CGRectMake(640, 15, 300,40)];    
    }
    else {
        [text setFrame:CGRectMake(390,15,300,50)];
    }


    text.font = [UIFont systemFontOfSize:20];
    text.layer.cornerRadius = 20;
    text.delegate=self; 
    [text setTextColor:[UIColor blackColor]];
    text.alpha=1.0;
    text.autocorrectionType = UITextAutocorrectionTypeNo;
    text.returnKeyType=UIReturnKeySearch;
    UIImageView *searchLogo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon-search-black.png"]];
    [text  setLeftView:searchLogo];
    [text setLeftViewMode:UITextFieldViewModeAlways];
    [searchLogo release];
    text.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    text.borderStyle=UITextBorderStyleRoundedRect;
    [text setBackgroundColor:[UIColor whiteColor]];

    [text setHidden:NO];
    [self addSubview:text];
    [text becomeFir开发者_JS百科stResponder];
}


It must be the borderStyle kicking in i.e.

text.borderStyle = UITextBorderStyleRoundedRect;

You can use UITextBorderStyleNone as you've customized the border style using cornerRadius.

0

精彩评论

暂无评论...
验证码 换一张
取 消