objective c - IOS align text placeholder to be in the center and left alignment -


i'm creating ios form submits feed back.

i want have placeholder text in center vertically , left alignment horizontal in text field

i have tried this

- (void)drawplaceholderinrect:(cgrect)rect {     [rgb(36, 84, 157) setfill];      uifont *font = [uifont singpostlightitalicfontofsize:_placeholderfontsize fontkey:ksingpostfontopensans];     nsmutableparagraphstyle *paragraphstyle = [[nsparagraphstyle defaultparagraphstyle] mutablecopy];     paragraphstyle.linebreakmode = nslinebreakbywordwrapping;     paragraphstyle.alignment = nstextalignmentleft;     nsdictionary *attributes = @{ nsfontattributename: font,                                   nsparagraphstyleattributename: paragraphstyle,                                   nsforegroundcolorattributename: [uicolor blackcolor]};     [[self placeholder] drawinrect:rect withattributes:attributes];  } 

but place holder text on top vertical. how can achieve gold. lot

enter image description here

the following code solve problem. tried myself. it's 1 additional line code.

- (void)drawplaceholderinrect:(cgrect)rect {         cgfloat fontsize = 18;        uifont *font = [uifont systemfontofsize:fontsize];        nsmutableparagraphstyle *paragraphstyle = [[nsparagraphstyle defaultparagraphstyle] mutablecopy];        paragraphstyle.linebreakmode = nslinebreakbywordwrapping;        paragraphstyle.alignment = nstextalignmentleft;         nsdictionary *attributes = @{ nsfontattributename: font,                               nsparagraphstyleattributename: paragraphstyle,        nsforegroundcolorattributename: [uicolor blackcolor]};         cgrect newrect = cgrectinset(rect, 0, rect.size.height/2 - fontsize/2);        [[super placeholder] drawinrect:newrect withattributes:attributes]; } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -