ios6 - Is it possible to create a UITextField in iOS 6 with only a bottom border? -


i want customize uitextfield in ios 6 transparent text field bottom border.i have found 1 image in stackoverflow earlier,but don't have 10 reputation can't post image,but posting link below.

text field bottom border in ios6

there multiple ways accomplish this:

  1. create seperatorview , add subview uitextfield y axis height of textfield.

    uitextfield *namefield = [[uitextfield alloc] initwithframe:cgrectmake(20,40,70,40)  ]; uiview *seperator=[uiview new]; seperator.backgroundcolor = [uicolor graycolor]; seperator.frame =cgrectmake(namefield.frame.origin.x, namefield frame.origin.y+namefield.frame.size.height-1, namefield.frame.size.width,1); [namefield addsubview:seperator]; 
  2. by using coreanimation class

    calayer *bottomborder = [calayer layer];    cgfloat borderwidth = 1; bottomborder.bordercolor = [uicolor graycolor].cgcolor;  bottomborder.frame = cgrectmake(0, textfield.frame.size.height - borderwidth, textfield.frame.size.width, textfield.frame.size.height);    bottomborder.borderwidth = borderwidth;   [textfield.layer addsublayer:border]; textfield.layer.maskstobounds = yes; 
  3. by creating custom class uitextfield , overriding drawrect method.

  4. using image , adding backgroundcolor uitextfield.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -