如何在UIButton上添加UIButton?
这样,如果我移动父UIButton,上面的那个也会移动。
发布于 2012-12-14 20:50:30
UIButton *testButton = [UIButton buttonWithType:UIButtonTypeCustom];
testButton.backgroundColor = [UIColor redColor];
UIButton *smallerButton = [UIButton buttonWithType:UIButtonTypeCustom];
smallerButton.backgroundColor = [UIColor greenColor];
[testButton addSubview:smallerButton];
[self.view addSubview:testButton];发布于 2012-12-14 20:48:32
[oneButton addSubview:otherButton];请记住,UIButton是UIView的子类...
发布于 2012-12-14 20:49:09
UIButton *parentBtn;
UIButton *childBtn;
parentBtn = [UIButton buttonWithType: // init the button];
childBtn = //same for child btn
[self.view addSubview:parentBtn]; //add the parent button to the view
[parentBtn addSubview:childBtn]; //add the child button on top of the parent buttonhttps://stackoverflow.com/questions/13878980
复制相似问题