From e3593b52583009354cd5a7e2a681ed16f3c99f88 Mon Sep 17 00:00:00 2001 From: Andrew Velis Date: Mon, 8 Apr 2013 23:52:21 -0700 Subject: [PATCH] Usage of CGRectGetMidX Change to use simplified calculation of knobCenter and textSpaceWidth. --- DCRoundSwitch/DCRoundSwitchToggleLayer.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DCRoundSwitch/DCRoundSwitchToggleLayer.m b/DCRoundSwitch/DCRoundSwitchToggleLayer.m index 99e0550..a526186 100644 --- a/DCRoundSwitch/DCRoundSwitchToggleLayer.m +++ b/DCRoundSwitch/DCRoundSwitchToggleLayer.m @@ -46,7 +46,7 @@ - (UIFont *)labelFont - (void)drawInContext:(CGContextRef)context { CGFloat knobRadius = self.bounds.size.height - 2.0; - CGFloat knobCenter = self.bounds.size.width / 2.0; + CGFloat knobCenter = CGRectGetMidX(self.bounds); CGRect knobRect = CGRectMake(knobCenter - knobRadius / 2.0, 1.0, knobRadius, knobRadius); if (self.clip) @@ -76,7 +76,7 @@ - (void)drawInContext:(CGContextRef)context // strings - CGFloat textSpaceWidth = (self.bounds.size.width / 2) - (knobRadius / 2); + CGFloat textSpaceWidth = CGRectGetMidX(self.bounds) - (knobRadius / 2); UIGraphicsPushContext(context);