2012-08-29 71 views
1

我沒有太多的經驗,但我想在兩個UIButtons在一個矩形內,如下圖所示。那麼最好的辦法是什麼?我不想從Photoshop中繪製矩形的圖像並導入到xCode中。謝謝iOS:如何在矩形內創建按鈕?

enter image description here

回答

1

你可以拖動一個UIView到你的故事板 ,然後拖動按鈕到這一點,所以他們是子視圖。 ,故事情節看起來像:

view controller 
    -view (main) 
     -view (your new subview) 
      -button1 
      -button2 

然後你可以設置背景等的子視圖直觀地定義

+0

我不是用故事板的矩形,是一樣的,而無需使用故事板? – DavidNg

+0

我不明白。但是 你可以通過編程來實現: 'UIView * theRectangle = [UIView initWithFrame(theRectangleFrame)]; UIButton button1 = [UIButton ... etc UIButton button2 = [UIButton ... etc [theRectangle addSubview:button1]; [theRectangle addSubview:button2]; [mainView addSubview:theRectangle];' ' – ball2000