« first day (2196 days earlier)      last day (744 days later) » 

6:39 AM
Good Morning All,
I have to implement TextField with underlined text. Do I want to set underline to entered text how can I achieve this? Please help me.
@DilipTi @ShobhakarTiwari
 
6:57 AM
@PallaviNikumbh hiii
how ru
r u there?
@PallaviNikumbh
sorry i was away
tell me now
 
7:11 AM
Hello @DilipTiwari
 
yes tell me
what exactly ur needs
 
Actually, I want to implement textfiled with underline text while editing underline also edited as per text.
how can I achieve this?
 
so u want particular bottom bottom border to be always underline
?
 
bottom border right ?
at the time of editing and also when not editing right ?
@PallaviNikumbh
 
7:15 AM
but, underline length depends on the text. means if user types 'A' only 'A' have underline.
 
> at the time of editing and also when not editing right ? : Yes right
 
means u didnot want textfield border
to be underline
 
only text
 
7:15 AM
yup
 
right
 
ok pallavi wait
2 min
 
ok waiting
 
ok
@PallaviNikumbh have u heard about NSAttributedString?
 
7:26 AM
Yes. and I have set this but text was not set
 
wait
var attrs = [
NSFontAttributeName : UIFont.systemFontOfSize(19.0),
NSForegroundColorAttributeName : UIColor.redColor(),
NSUnderlineStyleAttributeName : 1]

var attributedString = NSMutableAttributedString(string:"")
declare these
inside class
as global
/// write in textField didBeginEditing

let textFieldTextStr = NSMutableAttributedString(string: self.textFieldName.text, attributes:attrs)
attributedString.appendAttributedString(textFieldTextStr)
self.textFieldName.text.setAttributedTitle(attributedString, forState: .Normal)
check this @PallaviNikumbh and let me know it is working or not
 
7:39 AM
ok
 
@DilipTiwari I am getting error that is Value of type 'String' has no member 'setAttributedTitle'
 
its not updated as per ur version
check with these answers
39
Q: Underline button text in swift

moonvaderI have UIButton. In interface builder i set it's title to be 'Attributed'. How can i make it's title to be underlined from code in swift? @IBOutlet weak var myBtn: UIButton! I created function called on touchUpInside event of this button var attributedString = NSMutableAttributedString(string...

 
No, here they are setting the title for the button that's why they use 'setAttributedTitle'. I have to set the text field title.
 
i know that u want for textfield
let me check and let u know
can u share screenshot
@PallaviNikumbh
of error where u r getting
@PallaviNikumbh hii
use below code
and let me know
remove all code which i shared earlier
use only this one
        let underlineAttribute = [NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue]
        let underlineAttributedString = NSAttributedString(string: self.first_name.text!, attributes: underlineAttribute)
        first_name.attributedText = underlineAttributedString
@PallaviNikumbh
check and let me know its working or not
 
8:13 AM
@PallaviNikumbh above code is working fine
i checked now
use just abouve which i sended
r u there
func textFieldDidBeginEditing(_ textField: UITextField) {


if(textField == first_name){

let underlineAttribute = [NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue]
let underlineAttributedString = NSAttributedString(string: self.first_name.text!, attributes: underlineAttribute)
first_name.attributedText = underlineAttributedString
}
}
like this
 
 
1 hour later…
9:31 AM
hello @DilipTiwari ,
Let me check
 
@PallaviNikumbh yes pls check let me know once checked
 
10:08 AM
@PallaviNikumbh issues solved ?
 
10:46 AM
@DilipTiwari Will definitely let you know tomorrow coz have another high prio work. :)
 
10:56 AM
@PallaviNikumbh sure no issues i have tried in my project and it worked with same code
 
11:26 AM
W@p
@PallaviNikumbh : issue solved or not
?
 
11:41 AM
@ShobhakarTiwari hii how r u bro?
 
11:52 AM
m good
 
12:13 PM
OK
 

« first day (2196 days earlier)      last day (744 days later) »