3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UI部品を複数動的作成

Last updated at Posted at 2015-04-02

はじめに
この記事はobjective-cで見た記事をswiftに書き直しただけで、しかも適当な自分用のメモです。(要は間違ってたりしても許して下さい。)

まずNSMutableArrayを用意

var buttons=NSMutableArray()

UIbutton作成のタイミングでNSMutableArrayに追加

tagも追加

for i in 1...10{

var tmp=UIButton(frame:CGRectMake(10,CGFloat(20*i+20),100,50))

tmp.setTitle(textArray[i].forState:UIControlState.Normal)

tmp.addTarget(self,action:"buttontupped",forControlEvents.TouchUpInside)

tmp.tag=i

addSubview(tmp)

buttons .addObject(tmp)

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?