Permalink
Browse files

fixed the layout of the switch cell

  • Loading branch information...
kgn committed Jan 17, 2013
1 parent 3f6b703 commit fef69a5e7454a95eeb7d9d4618ac236a429ef74c
Showing with 8 additions and 5 deletions.
  1. +8 −5 InAppSettings/Cells/InAppSettingsPSToggleSwitchSpecifierCell.m
@@ -66,14 +66,17 @@ - (void)setupCell{
//create the switch
self.valueSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
- CGRect valueSwitchFrame = self.valueSwitch.frame;
- valueSwitchFrame.origin.y = (CGFloat)round((self.contentView.frame.size.height*0.5f)-(valueSwitchFrame.size.height*0.5f))-InAppSettingsOffsetY;
- valueSwitchFrame.origin.x = (CGFloat)round((CGRectGetWidth(self.bounds)-(InAppSettingsTotalTablePadding+InAppSettingsCellPadding))-valueSwitchFrame.size.width);
- self.valueSwitch.frame = valueSwitchFrame;
- self.valueSwitch.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[self.valueSwitch addTarget:self action:@selector(switchAction) forControlEvents:UIControlEventValueChanged];
[self.contentView addSubview:self.valueSwitch];
}
+- (void)layoutSubviews{
+ [super layoutSubviews];
+
+ CGRect valueSwitchFrame = self.valueSwitch.frame;
+ valueSwitchFrame.origin.y = (CGFloat)round(CGRectGetMidY(self.contentView.bounds)-CGRectGetMidY(self.valueSwitch.bounds))-InAppSettingsOffsetY;
+ valueSwitchFrame.origin.x = (CGFloat)round(CGRectGetWidth(self.contentView.bounds)-CGRectGetWidth(self.valueSwitch.bounds))-InAppSettingsCellPadding;
+ self.valueSwitch.frame = valueSwitchFrame;
+}
@end

0 comments on commit fef69a5

Please sign in to comment.