2014-11-21 82 views
0

我想在Scrollview中顯示標籤和按鈕。 有人可以告訴我這是怎麼完成的?在ScrollView中添加標籤Xcode Swift

@IBOutlet weak var PeopleView: UIScrollView! 

var button = UIButton.buttonWithType(UIButtonType.System) as UIButton 
    button.frame = CGRectMake("INSIDE SCROLL.VIEW", "INSIDE SCROLL.VIEW", 183, 21) 
    button.backgroundColor = UIColor.greenColor() 
    button.setTitle("Button", forState: UIControlState.Normal) 
    button.addTarget(self, action: "Action:", forControlEvents: UIControlEvents.TouchUpInside) 
    self.view.addSubview(button) 

回答

1

使用此行代碼

self.PeopleView.addSubview(button) 

代替

self.view.addSubview(button) 

,並確保你傳遞一個CGFloat值,同時給予按鈕或標籤幀

+0

非常完美的:) - 謝謝! – Heinevolder 2014-11-21 13:51:43

相關問題