uitextfield - Convert Obj-C to Swift -


trying override drawplaceholderinrect in swift2.1 change text color , having hard time converting following obj-c swift:

(void)drawplaceholderinrect:(cgrect)rect {     uicolor *colour = [uicolor whitecolor];      if ([self.placeholder respondstoselector:@selector(drawinrect:withattributes:)]) {      nsdictionary *attributes = @{nsforegroundcolorattributename: colour, nsfontattributename: self.font};     cgrect boundingrect = [self.placeholder boundingrectwithsize:rect.size options:0 attributes:attributes context:nil];     [self.placeholder drawatpoint:cgpointmake(0, (rect.size.height/2)-boundingrect.size.height/2) withattributes:attributes]; } 

i got this:

public override func drawplaceholderinrect(rect: cgrect) {     let textdict: nsdictionary = [nsforegroundcolorattributename: uicolor.whitecolor()]      ...     ..     . } 

can out please?

see if helpful:

https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/index.html#//apple_ref/doc/uid/tp40014216-ch2-id0

also, if have trouble translating objective-c swift, can tricky sometimes, consider overriding method in derived objective-c class , using class in swift.


Comments