Hello! Tell me, I have a resized UISwitch and when inserted into the AccessoryView in UITableViewCell it floats up and does not become in the middle, and if not resized, then everything is ok. But I really need to change. Here is the code:

switchButton = [UISwitch new]; _switchButton.transform = CGAffineTransformMakeScale(0.77, 0.64); [_switchButton setOnTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"selectedSegmentedControlColor"]]]; self.accessoryView = _switchButton; 

    3 answers 3

    Try setting an anchor point before decreasing.

     switchButton = [UISwitch new]; _switchButton.layer.anchorPoint = CGPointMake(0.5f, 0.5f); _switchButton.transform = CGAffineTransformMakeScale(0.77, 0.64); [_switchButton setOnTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"selectedSegmentedControlColor"]]]; self.accessoryView = _switchButton; 

      Try to change it like this:

       _switchButton.transform = CGAffineTransformMakeScale(0.5f, 0.5f); 

        try to put the switchButton on the cell and not use accessoryView for this. Yes, you may need to subclass the cell or somehow resize its views.