Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Last active June 14, 2016 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/1b18081e72bab4bbc8646c86b4efc72f to your computer and use it in GitHub Desktop.
Save chuck0523/1b18081e72bab4bbc8646c86b4efc72f to your computer and use it in GitHub Desktop.

学び

001

  • viewController内でのviewへの操作は、基本的には、self.view.hogehoge
    • viewパーツの追加は、self.view.addSubView(hoge)
  • 新規ラベルの定義
    • let myLabel: UILabel = UILabel(...
    • myLabelに対して、属性の追加を行っていく。
      • 色系はUIColorに入っている。
      • 配置はlayer.positionで指定。

002

  • UIボタンの定義は、let myButton = UIButton()
  • border-radiusは、myButton.layer.masksToBounds = true
    • ただし、myButton.layer.cornerRadius = 20のように数値指定が必要。
  • buttonはtextではなく、setTitleで文字を指定する。
    • myButton.setTitle("ボタン(通常)", forState: UIControlState.Normal)
    • myButton.setTitle("ボタン(押された時)", forState: UIControlState.Highlighted)
    • buttonの:activeはHighlightedなのか。
  • self.view.frame.widthでwindow.width的なものが取れる(たぶん)
  • アクション追加は、addTarget。引数は、対象、アクション関数、イベント種類。
  • (当然だけど、)アクションはviewDidLoad関数の外に書く。
internal func onClickMyButton(sender: UIButton) {
    print("onClickMyButton:")
    print("sender.currentTItle: \(sender.currentTitle)")
    print("sender.tag:\(sender.tag)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment