UIButton の上に UIButton を追加するにはどうすればよいですか?
親の UIButton を移動すると、一番上の UIButton も移動します。
UIButton の上に UIButton を追加するにはどうすればよいですか?
親の UIButton を移動すると、一番上の UIButton も移動します。
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];
[oneButton addSubview:otherButton];
それは...UIButton
のサブクラスであることを忘れないでくださいUIView
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 button