2015-12-29 36 views
-3

我在表格視圖單元格上創建了​​一個文本字段。但我希望能夠添加佔位符。將表格視圖單元格的文本字段添加佔位符

+0

[設置文本框的佔位符顏色progrmatically斯威夫特]的可能重複的東西(http://stackoverflow.com/questions/25679075/set-textfield-placeholder-color-progrmatically-in-swift) – milo526

+0

[UITextField佔位符文本疊加問題]的可能重複(http://stackoverflow.com/questions/21368468/uitextfield-placeholder-text-overlay-issue ) – jeffdill2

回答

1

您可以使用檢測面板中的佔位符字段,如下所示。如果您想這樣做編程,你可以使用類似於此

//create the attribute dictionary 
let placeholderAttr = [ 
    NSForegroundColorAttributeName: UIColor.lightGrayColor(), 
    NSFontAttributeName: UIFont(name: "HelveticaNeue-Light", size: 22.0)!, 
] 

//apply the attributes to the placeholder 
yourTextField.attributedPlaceholder = NSAttributedString(string: "This is your placeholder text", attributes: placeholderAttr) 
yourTextField.textAlignment = NSTextAlignment.Left 

Inspection panel - Placeholder

相關問題