我做了一個應用程序,它已經爲開發人員提供了API支持。想爲我的應用創建插件的開發人員只需調用一個方法「 - (void)createToggle」,UIButton就會自動添加到我的應用程序視圖中。問題是,我不知道如何在「 - (void)createToggle」中實現一種使UIButton在它們之間有一定距離(在這種情況下爲180)的方式。在它們之間的一定距離創建UIbuttons
我做了一個循環做到這一點,在這裏你可以看到代碼:
-(void)createToggle
{
for (unsigned int i=0; i<[[SPUtils dylibs] count]; i++)
{
toggle = [UIButton buttonWithType:UIButtonTypeCustom];
toggle.frame = CGRectMake(3487+180 *i, 27, 100, 100);
[toggle addTarget:self action:@selector(buttonTarget:) forControlEvents:UIControlEventTouchUpInside];
[toggleScroll addSubview:toggle];
}
}
我不清楚您發佈的代碼與您實際需要的代碼之間的區別。 –
是這段代碼顯示了你需要的東西,它完美的工作,你想在這個問題 –