omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    TextField.placeholder color

    Pythonista
    2
    3
    674
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DavinE
      DavinE last edited by

      Is it possible to change the placeholder color ?
      in my case its very dark so i can't read it very well...

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @DavinE last edited by cvp

        @DavinE try

        from objc_util import *
        import ui
        tf = ui.TextField()
        t = 'test'
        tf.placeholder = t
        tf.present('sheet')
        
        @on_main_thread
        def x():
        	o = ObjCInstance(tf)
        	stro=ObjCClass('NSMutableAttributedString').alloc().initWithString_(tf.placeholder)
        	color = UIColor.colorWithRed_green_blue_alpha_(1, 0.7, 0.7, 1)
        	stro.addAttribute_value_range_(ns('NSColor'),color,NSRange(0,len(t)))
        	o.textField().setAttributedPlaceholder_(stro)
        #print(dir(o.textField()))
        x()
        

        1 Reply Last reply Reply Quote 0
        • DavinE
          DavinE last edited by

          @cvp it works great thanks xD

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors