Last active
January 21, 2016 07:59
-
-
Save gitbricho/a36b06ebd1a31b449d7f to your computer and use it in GitHub Desktop.
xc-ui_control_01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: NSViewController { | |
// MARK:プロパティ | |
@IBOutlet weak var vテキスト: NSTextField! | |
@IBOutlet weak var vラベル: NSTextField! | |
@IBOutlet weak var vボタン: NSButton! | |
... | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: NSViewController { | |
// MARK:プロパティ | |
@IBOutlet weak var vテキスト: NSTextField! | |
@IBOutlet weak var vラベル: NSTextField! | |
@IBOutlet weak var vボタン: NSButton! | |
let l任意定数: Int = 5000 | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
//=== NSTextField ===== | |
//選択と編集の制御 | |
vテキスト.selectable = true | |
vテキスト.editable = true | |
//リッチテキストの制御 | |
vテキスト.allowsEditingTextAttributes = true | |
vテキスト.importsGraphics = false | |
//テキストカラーの設定 | |
vテキスト.textColor = NSColor.blueColor() | |
//自動レイアウトサイズ | |
vテキスト.preferredMaxLayoutWidth = 100.0 | |
//背景の制御 | |
vテキスト.backgroundColor = NSColor.yellowColor() | |
vテキスト.drawsBackground = false | |
//ボーダーの設定 | |
vテキスト.bordered = true | |
//テキストの選択 | |
vテキスト.selectText("") | |
//デリゲートの設定 | |
vテキスト.stringValue = "初期値" | |
let nsName:String = NSControlTextDidChangeNotification | |
vテキスト.delegate = textDidChange( | |
NSNotification(name: nsName, object: vテキスト)) | |
vテキスト.toolTip = "ツールチップ" | |
vテキスト.takeIntegerValueFrom(l任意定数) | |
vテキスト.delegate = textDidChange( | |
NSNotification(name: nsName, object: vテキスト)) | |
// | |
vラベル.textColor=NSColor.redColor() | |
} | |
override var representedObject: AnyObject? { | |
didSet { | |
// Update the view, if already loaded. | |
} | |
} | |
func textDidChange(notification: NSNotification) -> NSTextFieldDelegate? { | |
// | |
let fldtext = (notification.object as! NSTextField).stringValue | |
switch notification.name { | |
case NSControlTextDidChangeNotification: | |
print("change1:\(fldtext)") | |
default: | |
print("default") | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment