直接修改UISwitch frame是沒有效果的淡诗。
// This class enforces a size appropriate for the control, and so the frame size is ignored.
那么進(jìn)行 CGAffineTransformMakeScale
直接對(duì)UISwitch縮放编兄,最后顯示也會(huì)出現(xiàn)問題的.
正確的做法是將UISwitch用view包起來睁搭,然后縮放view就可以得到正確的效果钓猬。
UISwitch *switchButton = [[UISwitch alloc] init];
[switchButton addTarget:self action:@selector(switchButtonAction:) forControlEvents:UIControlEventValueChanged];
UIView *switchView = [UIView new];
switchView.frame = switchButton.bounds;
switchView.transform = CGAffineTransformMakeScale(0.65, 0.65);
switchView.ef_left = view.ef_width - switchView.ef_width;
switchView.ef_top = (view.ef_height - switchView.ef_height)/2.f;
[switchView addSubview:switchButton];
[view addSubview:switchView];