├── .gitignore ├── LICENSE ├── MSCellAccessory.podspec ├── MSCellAccessory ├── MSCellAccessory.h ├── MSCellAccessory.m ├── UIView+AccessViewController.h └── UIView+AccessViewController.m ├── MSCellAccessoryDemo.xcodeproj └── project.pbxproj ├── MSCellAccessoryDemo ├── AppDelegate.h ├── AppDelegate.m ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── MSCellAccessoryDemo-Info.plist ├── MSCellAccessoryDemo-Prefix.pch ├── ScreenShot.png ├── ScreenShot2.png ├── ScreenShot3.png ├── TBViewController.h ├── TBViewController.m ├── TBViewController.xib ├── en.lproj │ └── InfoPlist.strings └── main.m └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2013 SHIM MIN SEOK(bitmapdata.com@gmail.com) All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | Neither the name of Infrae nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INFRAE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /MSCellAccessory.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MSCellAccessory" 3 | s.version = "1.1.3" 4 | s.summary = "UITableViewCell accessoryType can easily customize the colors, Supported iOS7 Flat Design." 5 | s.homepage = "http://github.com/bitmapdata/MSCellAccessory" 6 | s.license = { :type => 'BSD', :file => 'LICENSE' } 7 | s.author = { "bitmapdata" => "bitmapdata.com@gmail.com" } 8 | s.source = { :git => "https://github.com/bitmapdata/MSCellAccessory.git", :tag => "1.1.3"} 9 | s.source_files = 'MSCellAccessory/*.{h,m}' 10 | s.requires_arc = true 11 | s.ios.deployment_target = "5.0" 12 | end -------------------------------------------------------------------------------- /MSCellAccessory/MSCellAccessory.h: -------------------------------------------------------------------------------- 1 | // 2 | // MSCellAccessory.h 3 | // MSCellAccessory 4 | // 5 | // Created by SHIM MIN SEOK on 13. 6. 19.. 6 | // 7 | // Software License Agreement (BSD License) 8 | // 9 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 10 | // 11 | // Redistribution and use in source and binary forms, with or without 12 | // modification, are permitted provided that the following conditions are met: 13 | // 14 | // 1. Redistributions of source code must retain the above copyright 15 | // notice, this list of conditions and the following disclaimer. 16 | // 17 | // 2. Redistributions in binary form must reproduce the above copyright 18 | // notice, this list of conditions and the following disclaimer in 19 | // the documentation and/or other materials provided with the 20 | // distribution. 21 | // 22 | // 3. Neither the name of Infrae nor the names of its contributors may 23 | // be used to endorse or promote products derived from this software 24 | // without specific prior written permission. 25 | // 26 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INFRAE OR 30 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 32 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 34 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | // 38 | 39 | #import 40 | 41 | /* 42 | ------------------------------------------------------------------------------------------------------------------------------------------------------ 43 | 44 | *** iOS7 Flat Design 45 | 46 | FLAT_DETAIL_DISCLOSURE: identical to iOS7 UITableViewCellAccessoryDetailDisclosureButton 47 | 48 | FLAT_DETAIL_BUTTON: identical to iOS7 UITableViewCellAccessoryDetailButton 49 | 50 | FLAT_DISCLOSURE_INDICATOR: identical to iOS7 UITableViewCellAccessoryDisclosureIndicator 51 | 52 | FLAT_CHECKMARK: identical to iOS7 UITableViewCellAccessoryCheckmark 53 | 54 | FLAT_UNFOLD_INDICATOR: Flat unfold indicator 55 | 56 | FLAT_FOLD_INDICATOR: Flat fold indicator 57 | 58 | ------------------------------------------------------------------------------------------------------------------------------------------------------ 59 | 60 | *** Prior to iOS7 61 | 62 | DETAIL_DISCLOSURE: identical to UITableViewCellAccessoryDetailDisclosureButton 63 | 64 | DISCLOSURE_INDICATOR: identical to UITableViewCellAccessoryDisclosureIndicator 65 | 66 | CHECKMARK: identical to UITableViewCellAccessoryCheckmark 67 | 68 | UNFOLD_INDICATOR: unfold indicator 69 | 70 | FOLD_INDICATOR: fold indicator 71 | 72 | ------------------------------------------------------------------------------------------------------------------------------------------------------ 73 | */ 74 | 75 | #define DETAIL_DISCLOSURE_DEFAULT_COLOR [UIColor colorWithRed:35/255.0 green:110/255.0 blue:216/255.0 alpha:1.0] 76 | #define DISCLOSURE_INDICATOR_DEFAULT_COLOR [UIColor colorWithRed:127/255.0 green:127/255.0 blue:127/255.0 alpha:1.0] 77 | #define CHECKMARK_DEFAULT_DEFAULT_COLOR [UIColor colorWithRed:50/255.0 green:79/255.0 blue:133/255.0 alpha:1.0] 78 | #define FLAT_DETAIL_BUTTON_DEFAULT_COLOR [UIColor colorWithRed:0/255.0 green:122/255.0 blue:255/255.0 alpha:1.0] 79 | #define FLAT_DISCLOSURE_INDICATOR_DEFAULT_COLOR [UIColor colorWithRed:199/255.0 green:199/255.0 blue:204/255.0 alpha:1.0] 80 | #define FLAT_CHECKMARK_DEFAULT_COLOR [UIColor colorWithRed:0/255.0 green:122/255.0 blue:255/255.0 alpha:1.0] 81 | 82 | typedef NS_ENUM(NSInteger, MSCellAccessoryType) 83 | { 84 | NONE, 85 | DETAIL_DISCLOSURE, 86 | DISCLOSURE_INDICATOR, 87 | CHECKMARK, 88 | UNFOLD_INDICATOR, 89 | FOLD_INDICATOR, 90 | PLUS_INDICATOR, 91 | MINUS_INDICATOR, 92 | FLAT_DETAIL_DISCLOSURE, 93 | FLAT_DETAIL_BUTTON, 94 | FLAT_DISCLOSURE_INDICATOR, 95 | FLAT_CHECKMARK, 96 | FLAT_UNFOLD_INDICATOR, 97 | FLAT_FOLD_INDICATOR, 98 | FLAT_PLUS_INDICATOR, 99 | FLAT_MINUS_INDICATOR 100 | }; 101 | 102 | @interface MSCellAccessory : UIControl 103 | @property (nonatomic, assign) MSCellAccessoryType accType; 104 | @property (nonatomic, assign) BOOL isAutoLayout; //default is YES. if set to NO, accessory layout does not adjust automatically. 105 | @property (nonatomic, assign) BOOL isAccessoryViewUserInteractionEnabled; //couples accessory view icon user interaction with the control 106 | 107 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType color:(UIColor *)color; 108 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType color:(UIColor *)color highlightedColor:(UIColor *)highlightedColor; 109 | 110 | // If you using a FLAT_DETAIL_DISCLOSURE, use these method. because FLAT_DETAIL_DISCLOSURE has a two different UI (FLAT_DETAIL_BUTTON, FLAT_DISCLOSURE_INDICATOR), must set a each color. 111 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType colors:(NSArray *)colors; 112 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType colors:(NSArray *)colors highlightedColors:(NSArray *)highlightedColors; 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /MSCellAccessory/MSCellAccessory.m: -------------------------------------------------------------------------------- 1 | // 2 | // MSCellAccessory.m 3 | // MSCellAccessory 4 | // 5 | // Created by SHIM MIN SEOK on 13. 6. 19.. 6 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 7 | // 8 | 9 | #import "MSCellAccessory.h" 10 | #import "UIView+AccessViewController.h" 11 | 12 | //if you change a UITableViewCell height, accessoryView this will affect change the right margin. so, the coordinates must be fixed. within layoutSubviews, drawRect. ( #issue prior to iOS7 ) 13 | #define kFixedPositionX (self.superview.frame.size.width - 38) 14 | #define kFlatDetailFixedPositionX (self.superview.frame.size.width - 58) 15 | 16 | #define kAccessoryViewRect CGRectMake(0, 0, 32.0, 32.0) 17 | #define kCircleRect CGRectMake(6.0, 3.5, 21.0, 21.0) 18 | #define kCircleOverlayRect CGRectMake(2.0, 12.5, 29.0, 21.0) 19 | #define kCircleShadowOverlayRect CGRectMake(6.0, 3.0, 21.0, 22.2) 20 | #define kStrokeWidth 2.0 21 | #define kShadowRadius 4.5 22 | #define kShadowOffset CGSizeMake(0.1, 1.2) 23 | #define kShadowColor [UIColor colorWithWhite:.0 alpha:1.] 24 | #define kDetailDisclosurePositon CGPointMake(20.0, 14.0) 25 | #define kDetailDisclosureRadius 5.5 26 | #define kHighlightedColorGapH 9.0/360.0 27 | #define kHighlightedColorGapS 9.5/100.0 28 | #define kHighlightedFlatColorGapS 80.0/100.0 29 | #define kHighlightedColorGapV -4.5/100.0 30 | #define kOverlayColorGapH 0.0/360.0 31 | #define kOverlayColorGapS -50.0/255.0 32 | #define kOverlayColorGapV 15.0/255.0 33 | 34 | #define kDisclosureStartX CGRectGetMaxX(self.bounds)-7.0 35 | #define kDisclosureStartY CGRectGetMidY(self.bounds) 36 | #define kDisclosureRadius 4.5 37 | #define kDisclosureWidth 3.0 38 | #define kDisclosureShadowOffset CGSizeMake(.0, -1.0) 39 | #define kDisclosurePositon CGPointMake(18.0, 13.5) 40 | 41 | #define kCheckMarkStartX kAccessoryViewRect.size.width/2 + 1 42 | #define kCheckMarkStartY kAccessoryViewRect.size.height/2 - 1 43 | #define kCheckMarkLCGapX 3.5 44 | #define kCheckMarkLCGapY 5.0 45 | #define kCheckMarkCRGapX 10.0 46 | #define kCheckMarkCRGapY -6.0 47 | #define kCheckMarkWidth 2.5 48 | 49 | #define kToggleIndicatorStartX CGRectGetMaxX(self.bounds)-10.0 50 | #define kToggleIndicatorStartY CGRectGetMidY(self.bounds) 51 | #define kToggleIndicatorRadius 5.5 52 | #define kToggleIndicatorLineWidth 3.5 53 | 54 | #define kAddIndicatorShadowOffset CGSizeMake(.0f, -1.f) 55 | 56 | #define FLAT_ACCESSORY_VIEW_RECT CGRectMake(0, 0, 52.0, 32.0) 57 | #define FLAT_STROKE_WIDTH 1.0 58 | #define FLAT_DETAIL_CIRCLE_RECT CGRectMake(10.5, 5.5, 21.0, 21.0) 59 | #define FLAT_DETAIL_BUTTON_DOT_FRAME CGRectMake(19.6, 9.5, 2.6, 2.6) 60 | #define FLAT_DETAIL_BUTTON_VERTICAL_WIDTH 2.0 61 | #define FLAT_DETAIL_BUTTON_VERTICAL_START_POINT CGPointMake(21, 13.5) 62 | #define FLAT_DETAIL_BUTTON_VERTICAL_END_POINT CGPointMake(21, 21.5) 63 | #define FLAT_DETAIL_BUTTON_HORIZONTAL_WIDTH 0.5 64 | #define FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_START_POINT CGPointMake(19.0, 13.5 + FLAT_DETAIL_BUTTON_HORIZONTAL_WIDTH * 0.5) 65 | #define FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_END_POINT CGPointMake(21.0, 13.5 + FLAT_DETAIL_BUTTON_HORIZONTAL_WIDTH * 0.5) 66 | #define FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_START_POINT CGPointMake(19.0, 21.5 + FLAT_DETAIL_BUTTON_HORIZONTAL_WIDTH * 0.5) 67 | #define FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_END_POINT CGPointMake(23.0, 21.5 + FLAT_DETAIL_BUTTON_HORIZONTAL_WIDTH * 0.5) 68 | 69 | #define FLAT_DISCLOSURE_START_X CGRectGetMaxX(self.bounds)-1.5 70 | #define FLAT_DISCLOSURE_START_Y CGRectGetMidY(self.bounds)+0.25 71 | #define FLAT_DISCLOSURE_RADIUS 4.8 72 | #define FLAT_DISCLOSURE_WIDTH 2.2 73 | #define FLAT_DISCLOSURE_SHADOW_OFFSET CGSizeMake(.0, -1.0) 74 | #define FLAT_DISCLOSURE_POSITON CGPointMake(18.0, 13.5) 75 | 76 | #define FLAT_CHECKMARK_START_X kAccessoryViewRect.size.width/2 + 4.25 77 | #define FLAT_CHECKMARK_START_Y kAccessoryViewRect.size.height/2 + 1.25 78 | #define FLAT_CHECKMARK_LC_GAP_X 2.5 79 | #define FLAT_CHECKMARK_LC_GAP_Y 2.5 80 | #define FLAT_CHECKMARK_CR_GAP_X 9.875 81 | #define FLAT_CHECKMARK_CR_GAP_Y -4.375 82 | #define FLAT_CHECKMARK_WIDTH 2.125 83 | 84 | #define FLAT_TOGGLE_INDICATOR_START_X CGRectGetMaxX(self.bounds)-7.0 85 | #define FLAT_TOGGLE_INDICATOR_START_Y CGRectGetMidY(self.bounds) 86 | #define FLAT_TOGGLE_INDICATOR_RADIUS 5.0 87 | #define FLAT_TOGGLE_INDICATOR_LINE_WIDTH 2.0 88 | 89 | #define kFlatDrawLineWidth 1.0 90 | #define kFlatLineStartX 4.5 91 | #define kFlatLineStartY 4.5 92 | #define kFlatLineWidth 11.0 93 | #define kFlatLineHeight 11.0 94 | 95 | @interface MSCellAccessory() 96 | @property (nonatomic, strong) UIColor *accessoryColor; 97 | @property (nonatomic, strong) UIColor *highlightedColor; 98 | @property (nonatomic, strong) NSArray *accessoryColors; 99 | @property (nonatomic, strong) NSArray *highlightedColors; 100 | @end 101 | 102 | @implementation MSCellAccessory 103 | 104 | #pragma mark - Factory 105 | 106 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType color:(UIColor *)color 107 | { 108 | return [self accessoryWithType:accessoryType color:color highlightedColor:NULL]; 109 | } 110 | 111 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType color:(UIColor *)color highlightedColor:(UIColor *)highlightedColor 112 | { 113 | return [[MSCellAccessory alloc] initWithFrame:kAccessoryViewRect color:color highlightedColor:highlightedColor accessoryType:accessoryType]; 114 | } 115 | 116 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType colors:(NSArray *)colors 117 | { 118 | if(accessoryType != FLAT_DETAIL_DISCLOSURE) 119 | return [self accessoryWithType:accessoryType color:colors[0]]; 120 | 121 | return [self accessoryWithType:accessoryType colors:colors highlightedColors:NULL]; 122 | } 123 | 124 | + (MSCellAccessory *)accessoryWithType:(MSCellAccessoryType)accessoryType colors:(NSArray *)colors highlightedColors:(NSArray *)highlightedColors 125 | { 126 | if(accessoryType != FLAT_DETAIL_DISCLOSURE) 127 | return [self accessoryWithType:accessoryType color:colors[0] highlightedColor:highlightedColors[0]]; 128 | 129 | return [[MSCellAccessory alloc] initWithFrame:FLAT_ACCESSORY_VIEW_RECT colors:colors highlightedColors:highlightedColors accessoryType:accessoryType]; 130 | } 131 | 132 | #pragma mark - 133 | 134 | - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event 135 | { 136 | if(_accType == FLAT_DETAIL_BUTTON || _accType == DETAIL_DISCLOSURE || _accType == PLUS_INDICATOR) 137 | { 138 | if(point.x > 0) 139 | return YES; 140 | } 141 | else if(_accType == FLAT_DETAIL_DISCLOSURE) 142 | { 143 | if(point.x > -3 && point.x < 46) 144 | return YES; 145 | } 146 | 147 | return [super pointInside:point withEvent:event]; 148 | } 149 | 150 | - (id)initWithFrame:(CGRect)frame color:(UIColor *)color highlightedColor:(UIColor *)highlightedColor accessoryType:(MSCellAccessoryType)accessoryType 151 | { 152 | if ((self = [super initWithFrame:frame])) 153 | { 154 | self.backgroundColor = [UIColor clearColor]; 155 | self.accessoryColor = color; 156 | self.accType = accessoryType; 157 | self.isAutoLayout = YES; 158 | self.isAccessoryViewUserInteractionEnabled = NO; 159 | 160 | if(!highlightedColor) 161 | { 162 | if(_accType >= FLAT_DETAIL_DISCLOSURE) 163 | { 164 | if(_accType == FLAT_DETAIL_BUTTON) 165 | { 166 | CGFloat h = 0.f; 167 | CGFloat s = 0.f; 168 | CGFloat v = 0.f; 169 | CGFloat a = 0.f; 170 | // Crash below iOS 5 171 | if ([_accessoryColor respondsToSelector:@selector(getHue:saturation:brightness:alpha:)]) 172 | { 173 | [_accessoryColor getHue:&h saturation:&s brightness:&v alpha:&a]; 174 | } 175 | self.highlightedColor = [UIColor colorWithHue:h saturation:s-kHighlightedFlatColorGapS brightness:v alpha:a]; 176 | } 177 | else 178 | { 179 | self.highlightedColor = self.accessoryColor; 180 | } 181 | } 182 | else 183 | { 184 | CGFloat h = 0.f; 185 | CGFloat s = 0.f; 186 | CGFloat v = 0.f; 187 | CGFloat a = 0.f; 188 | // Crash below iOS 5 189 | if ([_accessoryColor respondsToSelector:@selector(getHue:saturation:brightness:alpha:)]) 190 | { 191 | [_accessoryColor getHue:&h saturation:&s brightness:&v alpha:&a]; 192 | } 193 | self.highlightedColor = [UIColor colorWithHue:h+kHighlightedColorGapH saturation:s+kHighlightedColorGapS brightness:v+kHighlightedColorGapV alpha:a]; 194 | } 195 | } 196 | else 197 | { 198 | self.highlightedColor = highlightedColor; 199 | } 200 | 201 | if(_accType == DETAIL_DISCLOSURE || _accType == FLAT_DETAIL_BUTTON) 202 | { 203 | [self setIsAccessoryViewUserInteractionEnabled:YES]; 204 | }else { 205 | [self setIsAccessoryViewUserInteractionEnabled:NO]; 206 | } 207 | } 208 | 209 | return self; 210 | } 211 | 212 | - (id)initWithFrame:(CGRect)frame colors:(NSArray *)colors highlightedColors:(NSArray *)highlightedColors accessoryType:(MSCellAccessoryType)accessoryType 213 | { 214 | if ((self = [super initWithFrame:frame])) 215 | { 216 | self.backgroundColor = [UIColor clearColor]; 217 | self.accessoryColors = colors; 218 | self.accType = accessoryType; 219 | self.isAutoLayout = YES; 220 | 221 | if(!highlightedColors) 222 | { 223 | CGFloat h,s,v,a; 224 | [colors[0] getHue:&h saturation:&s brightness:&v alpha:&a]; 225 | self.highlightedColors = @[[UIColor colorWithHue:h saturation:s-kHighlightedFlatColorGapS brightness:v alpha:a],colors[1]]; 226 | } 227 | else 228 | { 229 | self.highlightedColors = highlightedColors; 230 | } 231 | 232 | [self addTarget:self action:@selector(accessoryButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; 233 | } 234 | 235 | return self; 236 | } 237 | 238 | - (void)layoutSubviews 239 | { 240 | [super layoutSubviews]; 241 | 242 | if(!_isAutoLayout) return; 243 | //iOS5, iOS6 244 | if(![NSClassFromString(@"UIMotionEffect") class]) 245 | { 246 | UITableView *tb = [self ms_firstTableViewHierarchyFromView:self]; 247 | if(tb.style == UITableViewStylePlain) 248 | { 249 | CGRect frame = self.frame; 250 | if(_accType != FLAT_DETAIL_DISCLOSURE) 251 | frame.origin.x = kFixedPositionX; 252 | else 253 | frame.origin.x = kFlatDetailFixedPositionX; 254 | self.frame = frame; 255 | } 256 | } 257 | } 258 | 259 | - (void)accessoryButtonTapped:(id)sender event:(UIEvent *)event 260 | { 261 | UITableView *superTableView = [self ms_firstTableViewHierarchyFromView:self]; 262 | id tableDelegate = superTableView.delegate; 263 | UITableViewCell *superTableViewCell = [self ms_firstTableViewCellInHierarchyFromView:self];; 264 | NSIndexPath *indexPath = [superTableView indexPathForCell:superTableViewCell]; 265 | 266 | if ([tableDelegate respondsToSelector:@selector(tableView:accessoryButtonTappedForRowWithIndexPath:)]) { 267 | [tableDelegate tableView:superTableView accessoryButtonTappedForRowWithIndexPath:indexPath]; 268 | } else { 269 | NSAssert(0, @"superTableView.delegate must implement tableView:accessoryButtonTappedForRowWithIndexPath:"); 270 | } 271 | } 272 | 273 | - (void)drawRect:(CGRect)rect 274 | { 275 | if(_accType == DETAIL_DISCLOSURE) 276 | { 277 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 278 | UIBezierPath *ddCircle = [UIBezierPath bezierPathWithOvalInRect:kCircleRect]; 279 | 280 | CGContextSaveGState(ctx); 281 | { 282 | CGContextAddEllipseInRect(ctx, kCircleShadowOverlayRect); 283 | CGContextSetShadowWithColor(ctx, kShadowOffset, kShadowRadius, kShadowColor.CGColor ); 284 | CGContextDrawPath(ctx, kCGPathFill); 285 | } 286 | CGContextRestoreGState(ctx); 287 | 288 | CGContextSaveGState(ctx); 289 | { 290 | CGContextAddPath(ctx, ddCircle.CGPath); 291 | CGFloat h,s,v,a; 292 | UIColor *color = NULL; 293 | color = self.touchInside?_highlightedColor:_accessoryColor; 294 | [color getHue:&h saturation:&s brightness:&v alpha:&a]; 295 | UIColor *overlayColor = [UIColor colorWithHue:h saturation:s+kOverlayColorGapS brightness:v+kOverlayColorGapV alpha:a]; 296 | CGContextSetFillColorWithColor(ctx, overlayColor.CGColor); 297 | CGContextDrawPath(ctx, kCGPathFill); 298 | } 299 | CGContextRestoreGState(ctx); 300 | 301 | CGContextSaveGState(ctx); 302 | { 303 | CGContextAddPath(ctx, ddCircle.CGPath); 304 | CGContextClip(ctx); 305 | CGContextAddEllipseInRect(ctx, kCircleOverlayRect); 306 | CGContextSetFillColorWithColor(ctx, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 307 | CGContextDrawPath(ctx, kCGPathFill); 308 | } 309 | CGContextRestoreGState(ctx); 310 | 311 | CGContextSaveGState(ctx); 312 | { 313 | CGContextAddPath(ctx, ddCircle.CGPath); 314 | CGContextSetLineWidth(ctx, kStrokeWidth); 315 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 316 | CGContextDrawPath(ctx, kCGPathStroke); 317 | } 318 | CGContextRestoreGState(ctx); 319 | 320 | CGContextSaveGState(ctx); 321 | { 322 | CGContextSetShadowWithColor(ctx, kDisclosureShadowOffset, .0, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 323 | CGContextMoveToPoint(ctx, kDetailDisclosurePositon.x-kDetailDisclosureRadius, kDetailDisclosurePositon.y-kDetailDisclosureRadius); 324 | CGContextAddLineToPoint(ctx, kDetailDisclosurePositon.x, kDetailDisclosurePositon.y); 325 | CGContextAddLineToPoint(ctx, kDetailDisclosurePositon.x-kDetailDisclosureRadius, kDetailDisclosurePositon.y+kDetailDisclosureRadius); 326 | CGContextSetLineWidth(ctx, kDisclosureWidth); 327 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 328 | CGContextStrokePath(ctx); 329 | } 330 | CGContextRestoreGState(ctx); 331 | } 332 | else if(_accType == DISCLOSURE_INDICATOR) 333 | { 334 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 335 | CGContextMoveToPoint(ctx, kDisclosureStartX-kDisclosureRadius, kDisclosureStartY-kDisclosureRadius); 336 | CGContextAddLineToPoint(ctx, kDisclosureStartX, kDisclosureStartY); 337 | CGContextAddLineToPoint(ctx, kDisclosureStartX-kDisclosureRadius, kDisclosureStartY+kDisclosureRadius); 338 | CGContextSetLineCap(ctx, kCGLineCapSquare); 339 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 340 | CGContextSetLineWidth(ctx, kDisclosureWidth); 341 | 342 | if (self.highlighted) 343 | { 344 | [self.highlightedColor setStroke]; 345 | } 346 | else 347 | { 348 | [self.accessoryColor setStroke]; 349 | } 350 | 351 | CGContextStrokePath(ctx); 352 | } 353 | else if(_accType == CHECKMARK) 354 | { 355 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 356 | CGContextMoveToPoint(ctx, kCheckMarkStartX, kCheckMarkStartY); 357 | CGContextAddLineToPoint(ctx, kCheckMarkStartX + kCheckMarkLCGapX, kCheckMarkStartY + kCheckMarkLCGapY); 358 | CGContextAddLineToPoint(ctx, kCheckMarkStartX + kCheckMarkCRGapX, kCheckMarkStartY + kCheckMarkCRGapY); 359 | CGContextSetLineCap(ctx, kCGLineCapRound); 360 | CGContextSetLineJoin(ctx, kCGLineJoinRound); 361 | CGContextSetLineWidth(ctx, kCheckMarkWidth); 362 | 363 | if (self.highlighted) 364 | { 365 | [self.highlightedColor setStroke]; 366 | } 367 | else 368 | { 369 | [self.accessoryColor setStroke]; 370 | } 371 | 372 | CGContextStrokePath(ctx); 373 | } 374 | else if(_accType == UNFOLD_INDICATOR) 375 | { 376 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 377 | 378 | CGContextMoveToPoint( ctx, kToggleIndicatorStartX-kToggleIndicatorRadius, kToggleIndicatorStartY); 379 | CGContextAddLineToPoint(ctx, kToggleIndicatorStartX, kToggleIndicatorStartY+kToggleIndicatorRadius); 380 | CGContextAddLineToPoint(ctx, kToggleIndicatorStartX+kToggleIndicatorRadius, kToggleIndicatorStartY); 381 | CGContextSetLineCap(ctx, kCGLineCapSquare); 382 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 383 | CGContextSetLineWidth(ctx, kToggleIndicatorLineWidth); 384 | 385 | [self.accessoryColor setStroke]; 386 | 387 | CGContextStrokePath(ctx); 388 | } 389 | else if(_accType == FOLD_INDICATOR) 390 | { 391 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 392 | 393 | CGContextMoveToPoint( ctx, kToggleIndicatorStartX-kToggleIndicatorRadius, kToggleIndicatorStartY+kToggleIndicatorRadius); 394 | CGContextAddLineToPoint(ctx, kToggleIndicatorStartX, kToggleIndicatorStartY); 395 | CGContextAddLineToPoint(ctx, kToggleIndicatorStartX+kToggleIndicatorRadius, kToggleIndicatorStartY+kToggleIndicatorRadius); 396 | CGContextSetLineCap(ctx, kCGLineCapSquare); 397 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 398 | CGContextSetLineWidth(ctx, kToggleIndicatorLineWidth); 399 | 400 | [self.accessoryColor setStroke]; 401 | 402 | CGContextStrokePath(ctx); 403 | } 404 | else if(_accType == PLUS_INDICATOR) 405 | { 406 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 407 | UIBezierPath *ddCircle = [UIBezierPath bezierPathWithOvalInRect:kCircleRect]; 408 | 409 | CGContextSaveGState(ctx); 410 | { 411 | CGContextAddEllipseInRect(ctx, kCircleShadowOverlayRect); 412 | CGContextSetShadowWithColor(ctx, kShadowOffset, kShadowRadius, kShadowColor.CGColor ); 413 | CGContextDrawPath(ctx, kCGPathFill); 414 | } 415 | CGContextRestoreGState(ctx); 416 | 417 | CGContextSaveGState(ctx); 418 | { 419 | CGContextAddPath(ctx, ddCircle.CGPath); 420 | CGFloat h,s,v,a; 421 | UIColor *color = NULL; 422 | color = self.touchInside?_highlightedColor:_accessoryColor; 423 | [color getHue:&h saturation:&s brightness:&v alpha:&a]; 424 | UIColor *overlayColor = [UIColor colorWithHue:h saturation:s+kOverlayColorGapS brightness:v+kOverlayColorGapV alpha:a]; 425 | CGContextSetFillColorWithColor(ctx, overlayColor.CGColor); 426 | CGContextDrawPath(ctx, kCGPathFill); 427 | } 428 | CGContextRestoreGState(ctx); 429 | 430 | CGContextSaveGState(ctx); 431 | { 432 | CGContextAddPath(ctx, ddCircle.CGPath); 433 | CGContextClip(ctx); 434 | CGContextAddEllipseInRect(ctx, kCircleOverlayRect); 435 | CGContextSetFillColorWithColor(ctx, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 436 | CGContextDrawPath(ctx, kCGPathFill); 437 | } 438 | CGContextRestoreGState(ctx); 439 | 440 | CGContextSaveGState(ctx); 441 | { 442 | CGContextAddPath(ctx, ddCircle.CGPath); 443 | CGContextSetLineWidth(ctx, kStrokeWidth); 444 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 445 | CGContextDrawPath(ctx, kCGPathStroke); 446 | } 447 | CGContextRestoreGState(ctx); 448 | 449 | CGContextSaveGState(ctx); 450 | { 451 | CGContextSetShadowWithColor(ctx, kAddIndicatorShadowOffset, 0, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 452 | CGContextMoveToPoint(ctx, kDetailDisclosurePositon.x-3.5, kDetailDisclosurePositon.y-kDetailDisclosureRadius-1.0); 453 | CGContextAddLineToPoint(ctx, kDetailDisclosurePositon.x-3.5, kDetailDisclosurePositon.y+6.5); 454 | CGContextMoveToPoint(ctx, kDetailDisclosurePositon.x-10, kDetailDisclosurePositon.y); 455 | CGContextAddLineToPoint(ctx, kDetailDisclosurePositon.x+3, kDetailDisclosurePositon.y); 456 | CGContextSetLineWidth(ctx, kDisclosureWidth); 457 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 458 | CGContextStrokePath(ctx); 459 | } 460 | CGContextRestoreGState(ctx); 461 | } 462 | else if(_accType == MINUS_INDICATOR) 463 | { 464 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 465 | UIBezierPath *ddCircle = [UIBezierPath bezierPathWithOvalInRect:kCircleRect]; 466 | 467 | CGContextSaveGState(ctx); 468 | { 469 | CGContextAddEllipseInRect(ctx, kCircleShadowOverlayRect); 470 | CGContextSetShadowWithColor(ctx, kShadowOffset, kShadowRadius, kShadowColor.CGColor ); 471 | CGContextDrawPath(ctx, kCGPathFill); 472 | } 473 | CGContextRestoreGState(ctx); 474 | 475 | CGContextSaveGState(ctx); 476 | { 477 | CGContextAddPath(ctx, ddCircle.CGPath); 478 | CGFloat h,s,v,a; 479 | UIColor *color = NULL; 480 | color = self.touchInside?_highlightedColor:_accessoryColor; 481 | [color getHue:&h saturation:&s brightness:&v alpha:&a]; 482 | UIColor *overlayColor = [UIColor colorWithHue:h saturation:s+kOverlayColorGapS brightness:v+kOverlayColorGapV alpha:a]; 483 | CGContextSetFillColorWithColor(ctx, overlayColor.CGColor); 484 | CGContextDrawPath(ctx, kCGPathFill); 485 | } 486 | CGContextRestoreGState(ctx); 487 | 488 | CGContextSaveGState(ctx); 489 | { 490 | CGContextAddPath(ctx, ddCircle.CGPath); 491 | CGContextClip(ctx); 492 | CGContextAddEllipseInRect(ctx, kCircleOverlayRect); 493 | CGContextSetFillColorWithColor(ctx, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 494 | CGContextDrawPath(ctx, kCGPathFill); 495 | } 496 | CGContextRestoreGState(ctx); 497 | 498 | CGContextSaveGState(ctx); 499 | { 500 | CGContextAddPath(ctx, ddCircle.CGPath); 501 | CGContextSetLineWidth(ctx, kStrokeWidth); 502 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 503 | CGContextDrawPath(ctx, kCGPathStroke); 504 | } 505 | CGContextRestoreGState(ctx); 506 | 507 | CGContextSaveGState(ctx); 508 | { 509 | CGContextSetShadowWithColor(ctx, kAddIndicatorShadowOffset, 0, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 510 | CGContextMoveToPoint(ctx, kDetailDisclosurePositon.x-10, kDetailDisclosurePositon.y); 511 | CGContextAddLineToPoint(ctx, kDetailDisclosurePositon.x+3, kDetailDisclosurePositon.y); 512 | CGContextSetLineWidth(ctx, kDisclosureWidth); 513 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 514 | CGContextStrokePath(ctx); 515 | } 516 | CGContextRestoreGState(ctx); 517 | } 518 | else if(_accType == FLAT_DISCLOSURE_INDICATOR) 519 | { 520 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 521 | CGContextMoveToPoint(ctx, FLAT_DISCLOSURE_START_X-FLAT_DISCLOSURE_RADIUS, FLAT_DISCLOSURE_START_Y-FLAT_DISCLOSURE_RADIUS); 522 | CGContextAddLineToPoint(ctx, FLAT_DISCLOSURE_START_X, FLAT_DISCLOSURE_START_Y); 523 | CGContextAddLineToPoint(ctx, FLAT_DISCLOSURE_START_X-FLAT_DISCLOSURE_RADIUS, FLAT_DISCLOSURE_START_Y+FLAT_DISCLOSURE_RADIUS); 524 | CGContextSetLineCap(ctx, kCGLineCapSquare); 525 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 526 | CGContextSetLineWidth(ctx, FLAT_DISCLOSURE_WIDTH); 527 | 528 | if (self.highlighted) 529 | { 530 | [self.highlightedColor setStroke]; 531 | } 532 | else 533 | { 534 | [self.accessoryColor setStroke]; 535 | } 536 | 537 | CGContextStrokePath(ctx); 538 | 539 | } 540 | else if(_accType == FLAT_DETAIL_DISCLOSURE) 541 | { 542 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 543 | UIBezierPath *markCircle = [UIBezierPath bezierPathWithOvalInRect:FLAT_DETAIL_CIRCLE_RECT]; 544 | 545 | UIColor *color1 = (UIColor *)_accessoryColors[0]; 546 | UIColor *color2 = (UIColor *)_highlightedColors[0]; 547 | UIColor *color3 = (UIColor *)_accessoryColors[1]; 548 | UIColor *color4 = (UIColor *)_highlightedColors[1]; 549 | 550 | CGContextSaveGState(ctx); 551 | { 552 | CGContextAddPath(ctx, markCircle.CGPath); 553 | CGContextSetLineWidth(ctx, FLAT_STROKE_WIDTH); 554 | CGContextSetStrokeColorWithColor(ctx, self.touchInside?color2.CGColor:color1.CGColor); 555 | CGContextDrawPath(ctx, kCGPathStroke); 556 | CGContextSetLineCap(ctx, kCGLineCapSquare); 557 | } 558 | CGContextRestoreGState(ctx); 559 | 560 | CGContextSaveGState(ctx); 561 | { 562 | CGContextSetFillColorWithColor(ctx, self.touchInside?color2.CGColor:color1.CGColor); 563 | 564 | CGContextFillEllipseInRect(ctx, FLAT_DETAIL_BUTTON_DOT_FRAME); 565 | 566 | CGContextSetStrokeColorWithColor(ctx, self.touchInside?color2.CGColor:color1.CGColor); 567 | 568 | CGContextSetLineWidth(ctx, FLAT_DETAIL_BUTTON_VERTICAL_WIDTH); 569 | CGContextMoveToPoint(ctx, FLAT_DETAIL_BUTTON_VERTICAL_START_POINT.x, FLAT_DETAIL_BUTTON_VERTICAL_START_POINT.y); 570 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_BUTTON_VERTICAL_END_POINT.x, FLAT_DETAIL_BUTTON_VERTICAL_END_POINT.y); 571 | CGContextStrokePath(ctx); 572 | 573 | CGFloat lineWidth = FLAT_DETAIL_BUTTON_HORIZONTAL_WIDTH; 574 | CGContextSetLineWidth(ctx, lineWidth); 575 | CGContextMoveToPoint(ctx, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_START_POINT.x, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_START_POINT.y); 576 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_END_POINT.x, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_END_POINT.y); 577 | 578 | CGContextMoveToPoint(ctx, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_START_POINT.x, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_START_POINT.y); 579 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_END_POINT.x, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_END_POINT.y); 580 | CGContextStrokePath(ctx); 581 | } 582 | CGContextRestoreGState(ctx); 583 | 584 | CGContextSaveGState(ctx); 585 | { 586 | CGContextMoveToPoint(ctx, FLAT_DISCLOSURE_START_X-FLAT_DISCLOSURE_RADIUS, FLAT_DISCLOSURE_START_Y-FLAT_DISCLOSURE_RADIUS); 587 | CGContextAddLineToPoint(ctx, FLAT_DISCLOSURE_START_X, FLAT_DISCLOSURE_START_Y); 588 | CGContextAddLineToPoint(ctx, FLAT_DISCLOSURE_START_X-FLAT_DISCLOSURE_RADIUS, FLAT_DISCLOSURE_START_Y+FLAT_DISCLOSURE_RADIUS); 589 | CGContextSetLineCap(ctx, kCGLineCapSquare); 590 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 591 | CGContextSetLineWidth(ctx, FLAT_DISCLOSURE_WIDTH); 592 | 593 | if (self.highlighted) 594 | { 595 | [color4 setStroke]; 596 | } 597 | else 598 | { 599 | [color3 setStroke]; 600 | } 601 | CGContextStrokePath(ctx); 602 | } 603 | CGContextRestoreGState(ctx); 604 | } 605 | else if(_accType == FLAT_DETAIL_BUTTON) 606 | { 607 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 608 | UIBezierPath *markCircle = [UIBezierPath bezierPathWithOvalInRect:FLAT_DETAIL_CIRCLE_RECT]; 609 | 610 | CGContextSaveGState(ctx); 611 | { 612 | CGContextAddPath(ctx, markCircle.CGPath); 613 | CGContextSetLineWidth(ctx, FLAT_STROKE_WIDTH); 614 | CGContextSetStrokeColorWithColor(ctx, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 615 | CGContextDrawPath(ctx, kCGPathStroke); 616 | CGContextSetLineCap(ctx, kCGLineCapSquare); 617 | } 618 | CGContextRestoreGState(ctx); 619 | 620 | CGContextSaveGState(ctx); 621 | { 622 | CGContextSetFillColorWithColor(ctx, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 623 | 624 | CGContextFillEllipseInRect(ctx, FLAT_DETAIL_BUTTON_DOT_FRAME); 625 | 626 | CGContextSetStrokeColorWithColor(ctx, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 627 | 628 | CGContextSetLineWidth(ctx, FLAT_DETAIL_BUTTON_VERTICAL_WIDTH); 629 | CGContextMoveToPoint(ctx, FLAT_DETAIL_BUTTON_VERTICAL_START_POINT.x, FLAT_DETAIL_BUTTON_VERTICAL_START_POINT.y); 630 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_BUTTON_VERTICAL_END_POINT.x, FLAT_DETAIL_BUTTON_VERTICAL_END_POINT.y); 631 | CGContextStrokePath(ctx); 632 | 633 | CGFloat lineWidth = FLAT_DETAIL_BUTTON_HORIZONTAL_WIDTH; 634 | CGContextSetLineWidth(ctx, lineWidth); 635 | CGContextMoveToPoint(ctx, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_START_POINT.x, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_START_POINT.y); 636 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_END_POINT.x, FLAT_DETAIL_BUTTON_TOP_HORIZONTAL_END_POINT.y); 637 | 638 | CGContextMoveToPoint(ctx, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_START_POINT.x, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_START_POINT.y); 639 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_END_POINT.x, FLAT_DETAIL_BUTTON_BOTTOM_HORIZONTAL_END_POINT.y); 640 | CGContextStrokePath(ctx); 641 | } 642 | CGContextRestoreGState(ctx); 643 | } 644 | else if(_accType == FLAT_CHECKMARK) 645 | { 646 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 647 | CGContextMoveToPoint(ctx, FLAT_CHECKMARK_START_X, FLAT_CHECKMARK_START_Y); 648 | CGContextAddLineToPoint(ctx, FLAT_CHECKMARK_START_X + FLAT_CHECKMARK_LC_GAP_X, FLAT_CHECKMARK_START_Y + FLAT_CHECKMARK_LC_GAP_Y); 649 | CGContextMoveToPoint(ctx, FLAT_CHECKMARK_START_X + FLAT_CHECKMARK_LC_GAP_X + 0.5, FLAT_CHECKMARK_START_Y + FLAT_CHECKMARK_LC_GAP_Y); 650 | CGContextAddLineToPoint(ctx, FLAT_CHECKMARK_START_X + FLAT_CHECKMARK_CR_GAP_X, FLAT_CHECKMARK_START_Y + FLAT_CHECKMARK_CR_GAP_Y); 651 | CGContextSetLineCap(ctx, kCGLineCapSquare); 652 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 653 | CGContextSetLineWidth(ctx, FLAT_CHECKMARK_WIDTH); 654 | 655 | if (self.highlighted) 656 | { 657 | [self.highlightedColor setStroke]; 658 | } 659 | else 660 | { 661 | [self.accessoryColor setStroke]; 662 | } 663 | 664 | CGContextStrokePath(ctx); 665 | } 666 | else if(_accType == FLAT_UNFOLD_INDICATOR) 667 | { 668 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 669 | 670 | CGContextMoveToPoint( ctx, FLAT_TOGGLE_INDICATOR_START_X-FLAT_TOGGLE_INDICATOR_RADIUS, FLAT_TOGGLE_INDICATOR_START_Y); 671 | CGContextAddLineToPoint(ctx, FLAT_TOGGLE_INDICATOR_START_X, FLAT_TOGGLE_INDICATOR_START_Y+FLAT_TOGGLE_INDICATOR_RADIUS); 672 | CGContextAddLineToPoint(ctx, FLAT_TOGGLE_INDICATOR_START_X+FLAT_TOGGLE_INDICATOR_RADIUS, FLAT_TOGGLE_INDICATOR_START_Y); 673 | CGContextSetLineCap(ctx, kCGLineCapSquare); 674 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 675 | CGContextSetLineWidth(ctx, FLAT_TOGGLE_INDICATOR_LINE_WIDTH); 676 | 677 | [self.accessoryColor setStroke]; 678 | 679 | CGContextStrokePath(ctx); 680 | } 681 | else if(_accType == FLAT_FOLD_INDICATOR) 682 | { 683 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 684 | 685 | CGContextMoveToPoint( ctx, FLAT_TOGGLE_INDICATOR_START_X-FLAT_TOGGLE_INDICATOR_RADIUS, FLAT_TOGGLE_INDICATOR_START_Y+FLAT_TOGGLE_INDICATOR_RADIUS); 686 | CGContextAddLineToPoint(ctx, FLAT_TOGGLE_INDICATOR_START_X, FLAT_TOGGLE_INDICATOR_START_Y); 687 | CGContextAddLineToPoint(ctx, FLAT_TOGGLE_INDICATOR_START_X+FLAT_TOGGLE_INDICATOR_RADIUS, FLAT_TOGGLE_INDICATOR_START_Y+FLAT_TOGGLE_INDICATOR_RADIUS); 688 | CGContextSetLineCap(ctx, kCGLineCapSquare); 689 | CGContextSetLineJoin(ctx, kCGLineJoinMiter); 690 | CGContextSetLineWidth(ctx, FLAT_TOGGLE_INDICATOR_LINE_WIDTH); 691 | 692 | [self.accessoryColor setStroke]; 693 | 694 | CGContextStrokePath(ctx); 695 | } 696 | else if(_accType == FLAT_PLUS_INDICATOR) 697 | { 698 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 699 | 700 | UIBezierPath *markCircle = [UIBezierPath bezierPathWithOvalInRect:FLAT_DETAIL_CIRCLE_RECT]; 701 | 702 | CGContextSaveGState(ctx); 703 | { 704 | CGContextSetShadowWithColor(ctx, CGSizeMake(0, 2.5), 0, [UIColor colorWithWhite:243/255.0 alpha:1.0].CGColor); 705 | CGContextAddPath(ctx, markCircle.CGPath); 706 | CGContextDrawPath(ctx, kCGPathFill); 707 | CGContextSetBlendMode (ctx, kCGBlendModeNormal); 708 | } 709 | CGContextRestoreGState(ctx); 710 | 711 | CGContextSaveGState(ctx); 712 | { 713 | CGContextSetStrokeColorWithColor(ctx, _accessoryColor.CGColor); 714 | CGContextAddPath(ctx, markCircle.CGPath); 715 | CGContextSetFillColorWithColor(ctx, _accessoryColor.CGColor); 716 | CGContextDrawPath(ctx, kCGPathFillStroke); 717 | CGContextAddPath(ctx, markCircle.CGPath); 718 | CGContextDrawPath(ctx, kCGPathFillStroke); 719 | CGContextFillPath(ctx); 720 | } 721 | CGContextRestoreGState(ctx); 722 | 723 | CGContextSaveGState(ctx); 724 | { 725 | CGContextSetShadowWithColor(ctx, kAddIndicatorShadowOffset, 0, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 726 | CGContextMoveToPoint(ctx, FLAT_DETAIL_CIRCLE_RECT.origin.x + FLAT_DETAIL_CIRCLE_RECT.size.width/2.0 - kFlatDrawLineWidth/2.0, FLAT_DETAIL_CIRCLE_RECT.origin.y + kFlatLineStartY); 727 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_CIRCLE_RECT.origin.x + FLAT_DETAIL_CIRCLE_RECT.size.width/2.0 - kFlatDrawLineWidth/2.0, FLAT_DETAIL_CIRCLE_RECT.origin.y + kFlatLineStartY + kFlatLineHeight); 728 | CGContextMoveToPoint(ctx, FLAT_DETAIL_CIRCLE_RECT.origin.x + kFlatLineStartX, FLAT_DETAIL_CIRCLE_RECT.origin.y + FLAT_DETAIL_CIRCLE_RECT.size.height/2.0 - kFlatDrawLineWidth/2.0); 729 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_CIRCLE_RECT.origin.x + kFlatLineStartX + kFlatLineWidth, FLAT_DETAIL_CIRCLE_RECT.origin.y + FLAT_DETAIL_CIRCLE_RECT.size.height/2.0 - kFlatDrawLineWidth/2.0); 730 | CGContextSetLineWidth(ctx, kFlatDrawLineWidth); 731 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 732 | CGContextStrokePath(ctx); 733 | } 734 | CGContextRestoreGState(ctx); 735 | } 736 | else if(_accType == FLAT_MINUS_INDICATOR) 737 | { 738 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 739 | 740 | UIBezierPath *markCircle = [UIBezierPath bezierPathWithOvalInRect:FLAT_DETAIL_CIRCLE_RECT]; 741 | 742 | CGContextSaveGState(ctx); 743 | { 744 | CGContextSetShadowWithColor(ctx, CGSizeMake(0, 2.5), 0, [UIColor colorWithWhite:243/255.0 alpha:1.0].CGColor); 745 | CGContextAddPath(ctx, markCircle.CGPath); 746 | CGContextDrawPath(ctx, kCGPathFill); 747 | CGContextSetBlendMode (ctx, kCGBlendModeNormal); 748 | } 749 | CGContextRestoreGState(ctx); 750 | 751 | CGContextSaveGState(ctx); 752 | { 753 | CGContextSetStrokeColorWithColor(ctx, _accessoryColor.CGColor); 754 | CGContextAddPath(ctx, markCircle.CGPath); 755 | CGContextSetFillColorWithColor(ctx, _accessoryColor.CGColor); 756 | CGContextDrawPath(ctx, kCGPathFillStroke); 757 | CGContextAddPath(ctx, markCircle.CGPath); 758 | CGContextDrawPath(ctx, kCGPathFillStroke); 759 | CGContextFillPath(ctx); 760 | } 761 | CGContextRestoreGState(ctx); 762 | 763 | CGContextSaveGState(ctx); 764 | { 765 | CGContextSetShadowWithColor(ctx, kAddIndicatorShadowOffset, 0, self.touchInside?_highlightedColor.CGColor:_accessoryColor.CGColor); 766 | CGContextMoveToPoint(ctx, FLAT_DETAIL_CIRCLE_RECT.origin.x + kFlatLineStartX, FLAT_DETAIL_CIRCLE_RECT.origin.y + FLAT_DETAIL_CIRCLE_RECT.size.height/2.0 - kFlatDrawLineWidth/2.0); 767 | CGContextAddLineToPoint(ctx, FLAT_DETAIL_CIRCLE_RECT.origin.x + kFlatLineStartX + kFlatLineWidth, FLAT_DETAIL_CIRCLE_RECT.origin.y + FLAT_DETAIL_CIRCLE_RECT.size.height/2.0 - kFlatDrawLineWidth/2.0); 768 | CGContextSetLineWidth(ctx, kFlatDrawLineWidth); 769 | CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor); 770 | CGContextStrokePath(ctx); 771 | } 772 | CGContextRestoreGState(ctx); 773 | } 774 | 775 | if(!_isAutoLayout) return; 776 | 777 | //iOS5, iOS6 778 | if(![NSClassFromString(@"UIMotionEffect") class]) 779 | { 780 | UITableView *tb = [self ms_firstTableViewHierarchyFromView:self]; 781 | if(tb.style == UITableViewStylePlain) 782 | { 783 | CGRect frame = self.frame; 784 | if(_accType != FLAT_DETAIL_DISCLOSURE) 785 | frame.origin.x = kFixedPositionX; 786 | else 787 | frame.origin.x = kFlatDetailFixedPositionX; 788 | self.frame = frame; 789 | } 790 | else 791 | { 792 | CGRect frame = self.frame; 793 | if(_accType != FLAT_DETAIL_DISCLOSURE) 794 | frame.origin.x = kFixedPositionX - 10; 795 | else 796 | frame.origin.x = kFlatDetailFixedPositionX; 797 | self.frame = frame; 798 | } 799 | } 800 | } 801 | 802 | - (void)setHighlighted:(BOOL)highlighted 803 | { 804 | [super setHighlighted:highlighted]; 805 | 806 | [self setNeedsDisplay]; 807 | } 808 | 809 | - (UIColor *)accessoryColor 810 | { 811 | if (!_accessoryColor) 812 | { 813 | return [UIColor blackColor]; 814 | } 815 | 816 | return _accessoryColor; 817 | } 818 | 819 | - (UIColor *)highlightedColor 820 | { 821 | if (!_highlightedColor) 822 | { 823 | return [UIColor whiteColor]; 824 | } 825 | 826 | return _highlightedColor; 827 | } 828 | 829 | #pragma mark - Accessory View User Interaction 830 | 831 | -(void)setIsAccessoryViewUserInteractionEnabled:(BOOL)isAccessoryViewUserInteractionEnabled 832 | { 833 | if (_isAccessoryViewUserInteractionEnabled != isAccessoryViewUserInteractionEnabled) { 834 | 835 | _isAccessoryViewUserInteractionEnabled = isAccessoryViewUserInteractionEnabled; 836 | 837 | if (_isAccessoryViewUserInteractionEnabled) { 838 | [self addTarget:self action:@selector(accessoryButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; 839 | self.userInteractionEnabled = YES; 840 | }else { 841 | [self removeTarget:self action:@selector(accessoryButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; 842 | self.userInteractionEnabled = NO; 843 | } 844 | } 845 | } 846 | 847 | @end 848 | -------------------------------------------------------------------------------- /MSCellAccessory/UIView+AccessViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+AccessViewController.h 3 | // MSCellAccessory 4 | // 5 | // Created by SHIM MIN SEOK on 13. 7. 22.. 6 | // 7 | // Software License Agreement (BSD License) 8 | // 9 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 10 | // 11 | // Redistribution and use in source and binary forms, with or without 12 | // modification, are permitted provided that the following conditions are met: 13 | // 14 | // 1. Redistributions of source code must retain the above copyright 15 | // notice, this list of conditions and the following disclaimer. 16 | // 17 | // 2. Redistributions in binary form must reproduce the above copyright 18 | // notice, this list of conditions and the following disclaimer in 19 | // the documentation and/or other materials provided with the 20 | // distribution. 21 | // 22 | // 3. Neither the name of Infrae nor the names of its contributors may 23 | // be used to endorse or promote products derived from this software 24 | // without specific prior written permission. 25 | // 26 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INFRAE OR 30 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 32 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 34 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | // 38 | 39 | #import 40 | 41 | @interface UIView (AccessViewController) 42 | - (UIViewController *)viewController DEPRECATED_ATTRIBUTE; 43 | - (id)ms_traverseResponderChainForUIViewController; 44 | - (UITableView *)ms_firstTableViewHierarchyFromView:(UIView *)view; 45 | - (UITableViewCell *)ms_firstTableViewCellInHierarchyFromView:(UIView *)view; 46 | @end 47 | -------------------------------------------------------------------------------- /MSCellAccessory/UIView+AccessViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+AccessViewController.m 3 | // MSCellAccessory 4 | // 5 | // Created by SHIM MIN SEOK on 13. 7. 22.. 6 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 7 | // 8 | 9 | #import "UIView+AccessViewController.h" 10 | 11 | @implementation UIView (AccessViewController) 12 | - (UIViewController *)viewController; 13 | { 14 | id nextResponder = [self nextResponder]; 15 | if ([nextResponder isKindOfClass:[UIViewController class]]) { 16 | return nextResponder; 17 | } else { 18 | return nil; 19 | } 20 | } 21 | 22 | - (id)ms_traverseResponderChainForUIViewController { 23 | id nextResponder = [self nextResponder]; 24 | if ([nextResponder isKindOfClass:[UIViewController class]]) { 25 | return nextResponder; 26 | } else if ([nextResponder isKindOfClass:[UIView class]]) { 27 | return [nextResponder ms_traverseResponderChainForUIViewController]; 28 | } else { 29 | return nil; 30 | } 31 | } 32 | 33 | - (UITableView *)ms_firstTableViewHierarchyFromView:(UIView *)view 34 | { 35 | UIView *superView = view; 36 | while (superView.superview) { 37 | if ([superView.superview isKindOfClass:UITableView.class]) { 38 | return (UITableView *)superView.superview; 39 | } 40 | superView = superView.superview; 41 | } 42 | 43 | return nil; 44 | } 45 | 46 | - (UITableViewCell *)ms_firstTableViewCellInHierarchyFromView:(UIView *)view 47 | { 48 | UIView *superView = view; 49 | while (superView.superview) { 50 | if ([superView.superview isKindOfClass:UITableViewCell.class]) { 51 | return (UITableViewCell *)superView.superview; 52 | } 53 | superView = superView.superview; 54 | } 55 | 56 | return nil; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | EE12A32017896E2F00DC5124 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12A31F17896E2F00DC5124 /* UIKit.framework */; }; 11 | EE12A32217896E2F00DC5124 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12A32117896E2F00DC5124 /* Foundation.framework */; }; 12 | EE12A32417896E2F00DC5124 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12A32317896E2F00DC5124 /* CoreGraphics.framework */; }; 13 | EE12A32A17896E2F00DC5124 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EE12A32817896E2F00DC5124 /* InfoPlist.strings */; }; 14 | EE12A32C17896E2F00DC5124 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EE12A32B17896E2F00DC5124 /* main.m */; }; 15 | EE12A33217896E2F00DC5124 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = EE12A33117896E2F00DC5124 /* Default.png */; }; 16 | EE12A33417896E2F00DC5124 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE12A33317896E2F00DC5124 /* Default@2x.png */; }; 17 | EE12A33617896E2F00DC5124 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE12A33517896E2F00DC5124 /* Default-568h@2x.png */; }; 18 | EE12A34517896EB500DC5124 /* MSCellAccessory.m in Sources */ = {isa = PBXBuildFile; fileRef = EE12A34417896EB500DC5124 /* MSCellAccessory.m */; }; 19 | EE12A34B17897E6F00DC5124 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EE12A34717897E6F00DC5124 /* AppDelegate.m */; }; 20 | EE12A34C17897E6F00DC5124 /* TBViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE12A34917897E6F00DC5124 /* TBViewController.m */; }; 21 | EE12A34D17897E6F00DC5124 /* TBViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = EE12A34A17897E6F00DC5124 /* TBViewController.xib */; }; 22 | EE12A3571789BC7000DC5124 /* ScreenShot.png in Resources */ = {isa = PBXBuildFile; fileRef = EE12A3561789BC6F00DC5124 /* ScreenShot.png */; }; 23 | EE1928D5179CE96C00675920 /* UIView+AccessViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1928D4179CE96C00675920 /* UIView+AccessViewController.m */; }; 24 | EEAE19001798E21C001ED37E /* ScreenShot2.png in Resources */ = {isa = PBXBuildFile; fileRef = EEAE18FF1798E21C001ED37E /* ScreenShot2.png */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | EE12A31C17896E2F00DC5124 /* MSCellAccessoryDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MSCellAccessoryDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | EE12A31F17896E2F00DC5124 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 30 | EE12A32117896E2F00DC5124 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 31 | EE12A32317896E2F00DC5124 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 32 | EE12A32717896E2F00DC5124 /* MSCellAccessoryDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MSCellAccessoryDemo-Info.plist"; sourceTree = ""; }; 33 | EE12A32917896E2F00DC5124 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 34 | EE12A32B17896E2F00DC5124 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | EE12A32D17896E2F00DC5124 /* MSCellAccessoryDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MSCellAccessoryDemo-Prefix.pch"; sourceTree = ""; }; 36 | EE12A33117896E2F00DC5124 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 37 | EE12A33317896E2F00DC5124 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 38 | EE12A33517896E2F00DC5124 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 39 | EE12A34317896EB500DC5124 /* MSCellAccessory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSCellAccessory.h; sourceTree = ""; }; 40 | EE12A34417896EB500DC5124 /* MSCellAccessory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSCellAccessory.m; sourceTree = ""; }; 41 | EE12A34617897E6F00DC5124 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | EE12A34717897E6F00DC5124 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | EE12A34817897E6F00DC5124 /* TBViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TBViewController.h; sourceTree = ""; }; 44 | EE12A34917897E6F00DC5124 /* TBViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TBViewController.m; sourceTree = ""; }; 45 | EE12A34A17897E6F00DC5124 /* TBViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TBViewController.xib; sourceTree = ""; }; 46 | EE12A3561789BC6F00DC5124 /* ScreenShot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ScreenShot.png; sourceTree = ""; }; 47 | EE1928D3179CE96C00675920 /* UIView+AccessViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+AccessViewController.h"; sourceTree = ""; }; 48 | EE1928D4179CE96C00675920 /* UIView+AccessViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+AccessViewController.m"; sourceTree = ""; }; 49 | EEAE18FF1798E21C001ED37E /* ScreenShot2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ScreenShot2.png; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | EE12A31917896E2F00DC5124 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | EE12A32017896E2F00DC5124 /* UIKit.framework in Frameworks */, 58 | EE12A32217896E2F00DC5124 /* Foundation.framework in Frameworks */, 59 | EE12A32417896E2F00DC5124 /* CoreGraphics.framework in Frameworks */, 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | EE12A31317896E2F00DC5124 = { 67 | isa = PBXGroup; 68 | children = ( 69 | EE12A34217896EB500DC5124 /* MSCellAccessory */, 70 | EE12A32517896E2F00DC5124 /* MSCellAccessoryDemo */, 71 | EE12A31E17896E2F00DC5124 /* Frameworks */, 72 | EE12A31D17896E2F00DC5124 /* Products */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | EE12A31D17896E2F00DC5124 /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | EE12A31C17896E2F00DC5124 /* MSCellAccessoryDemo.app */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | EE12A31E17896E2F00DC5124 /* Frameworks */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | EE12A31F17896E2F00DC5124 /* UIKit.framework */, 88 | EE12A32117896E2F00DC5124 /* Foundation.framework */, 89 | EE12A32317896E2F00DC5124 /* CoreGraphics.framework */, 90 | ); 91 | name = Frameworks; 92 | sourceTree = ""; 93 | }; 94 | EE12A32517896E2F00DC5124 /* MSCellAccessoryDemo */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | EE12A34617897E6F00DC5124 /* AppDelegate.h */, 98 | EE12A34717897E6F00DC5124 /* AppDelegate.m */, 99 | EE12A34817897E6F00DC5124 /* TBViewController.h */, 100 | EE12A34917897E6F00DC5124 /* TBViewController.m */, 101 | EE12A34A17897E6F00DC5124 /* TBViewController.xib */, 102 | EE12A32617896E2F00DC5124 /* Supporting Files */, 103 | ); 104 | path = MSCellAccessoryDemo; 105 | sourceTree = ""; 106 | }; 107 | EE12A32617896E2F00DC5124 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | EE12A32717896E2F00DC5124 /* MSCellAccessoryDemo-Info.plist */, 111 | EE12A32817896E2F00DC5124 /* InfoPlist.strings */, 112 | EE12A32B17896E2F00DC5124 /* main.m */, 113 | EE12A32D17896E2F00DC5124 /* MSCellAccessoryDemo-Prefix.pch */, 114 | EE12A33117896E2F00DC5124 /* Default.png */, 115 | EE12A33317896E2F00DC5124 /* Default@2x.png */, 116 | EE12A33517896E2F00DC5124 /* Default-568h@2x.png */, 117 | EE12A3561789BC6F00DC5124 /* ScreenShot.png */, 118 | EEAE18FF1798E21C001ED37E /* ScreenShot2.png */, 119 | ); 120 | name = "Supporting Files"; 121 | sourceTree = ""; 122 | }; 123 | EE12A34217896EB500DC5124 /* MSCellAccessory */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | EE1928D3179CE96C00675920 /* UIView+AccessViewController.h */, 127 | EE1928D4179CE96C00675920 /* UIView+AccessViewController.m */, 128 | EE12A34317896EB500DC5124 /* MSCellAccessory.h */, 129 | EE12A34417896EB500DC5124 /* MSCellAccessory.m */, 130 | ); 131 | path = MSCellAccessory; 132 | sourceTree = ""; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXNativeTarget section */ 137 | EE12A31B17896E2F00DC5124 /* MSCellAccessoryDemo */ = { 138 | isa = PBXNativeTarget; 139 | buildConfigurationList = EE12A33F17896E2F00DC5124 /* Build configuration list for PBXNativeTarget "MSCellAccessoryDemo" */; 140 | buildPhases = ( 141 | EE12A31817896E2F00DC5124 /* Sources */, 142 | EE12A31917896E2F00DC5124 /* Frameworks */, 143 | EE12A31A17896E2F00DC5124 /* Resources */, 144 | ); 145 | buildRules = ( 146 | ); 147 | dependencies = ( 148 | ); 149 | name = MSCellAccessoryDemo; 150 | productName = MSCellAccessoryDemo; 151 | productReference = EE12A31C17896E2F00DC5124 /* MSCellAccessoryDemo.app */; 152 | productType = "com.apple.product-type.application"; 153 | }; 154 | /* End PBXNativeTarget section */ 155 | 156 | /* Begin PBXProject section */ 157 | EE12A31417896E2F00DC5124 /* Project object */ = { 158 | isa = PBXProject; 159 | attributes = { 160 | LastUpgradeCheck = 0460; 161 | ORGANIZATIONNAME = "http://www.bitmapdata.com"; 162 | }; 163 | buildConfigurationList = EE12A31717896E2F00DC5124 /* Build configuration list for PBXProject "MSCellAccessoryDemo" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = EE12A31317896E2F00DC5124; 171 | productRefGroup = EE12A31D17896E2F00DC5124 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | EE12A31B17896E2F00DC5124 /* MSCellAccessoryDemo */, 176 | ); 177 | }; 178 | /* End PBXProject section */ 179 | 180 | /* Begin PBXResourcesBuildPhase section */ 181 | EE12A31A17896E2F00DC5124 /* Resources */ = { 182 | isa = PBXResourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | EEAE19001798E21C001ED37E /* ScreenShot2.png in Resources */, 186 | EE12A32A17896E2F00DC5124 /* InfoPlist.strings in Resources */, 187 | EE12A33217896E2F00DC5124 /* Default.png in Resources */, 188 | EE12A33417896E2F00DC5124 /* Default@2x.png in Resources */, 189 | EE12A33617896E2F00DC5124 /* Default-568h@2x.png in Resources */, 190 | EE12A34D17897E6F00DC5124 /* TBViewController.xib in Resources */, 191 | EE12A3571789BC7000DC5124 /* ScreenShot.png in Resources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXResourcesBuildPhase section */ 196 | 197 | /* Begin PBXSourcesBuildPhase section */ 198 | EE12A31817896E2F00DC5124 /* Sources */ = { 199 | isa = PBXSourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | EE12A32C17896E2F00DC5124 /* main.m in Sources */, 203 | EE1928D5179CE96C00675920 /* UIView+AccessViewController.m in Sources */, 204 | EE12A34517896EB500DC5124 /* MSCellAccessory.m in Sources */, 205 | EE12A34B17897E6F00DC5124 /* AppDelegate.m in Sources */, 206 | EE12A34C17897E6F00DC5124 /* TBViewController.m in Sources */, 207 | ); 208 | runOnlyForDeploymentPostprocessing = 0; 209 | }; 210 | /* End PBXSourcesBuildPhase section */ 211 | 212 | /* Begin PBXVariantGroup section */ 213 | EE12A32817896E2F00DC5124 /* InfoPlist.strings */ = { 214 | isa = PBXVariantGroup; 215 | children = ( 216 | EE12A32917896E2F00DC5124 /* en */, 217 | ); 218 | name = InfoPlist.strings; 219 | sourceTree = ""; 220 | }; 221 | /* End PBXVariantGroup section */ 222 | 223 | /* Begin XCBuildConfiguration section */ 224 | EE12A33D17896E2F00DC5124 /* Debug */ = { 225 | isa = XCBuildConfiguration; 226 | buildSettings = { 227 | ALWAYS_SEARCH_USER_PATHS = NO; 228 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 229 | CLANG_CXX_LIBRARY = "libc++"; 230 | CLANG_ENABLE_OBJC_ARC = YES; 231 | CLANG_WARN_CONSTANT_CONVERSION = YES; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 236 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 237 | COPY_PHASE_STRIP = NO; 238 | GCC_C_LANGUAGE_STANDARD = gnu99; 239 | GCC_DYNAMIC_NO_PIC = NO; 240 | GCC_OPTIMIZATION_LEVEL = 0; 241 | GCC_PREPROCESSOR_DEFINITIONS = ( 242 | "DEBUG=1", 243 | "$(inherited)", 244 | ); 245 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 246 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 248 | GCC_WARN_UNUSED_VARIABLE = YES; 249 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 250 | ONLY_ACTIVE_ARCH = YES; 251 | SDKROOT = iphoneos; 252 | }; 253 | name = Debug; 254 | }; 255 | EE12A33E17896E2F00DC5124 /* Release */ = { 256 | isa = XCBuildConfiguration; 257 | buildSettings = { 258 | ALWAYS_SEARCH_USER_PATHS = NO; 259 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 260 | CLANG_CXX_LIBRARY = "libc++"; 261 | CLANG_ENABLE_OBJC_ARC = YES; 262 | CLANG_WARN_CONSTANT_CONVERSION = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INT_CONVERSION = YES; 266 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 267 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 268 | COPY_PHASE_STRIP = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 271 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 272 | GCC_WARN_UNUSED_VARIABLE = YES; 273 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 274 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 275 | SDKROOT = iphoneos; 276 | VALIDATE_PRODUCT = YES; 277 | }; 278 | name = Release; 279 | }; 280 | EE12A34017896E2F00DC5124 /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | CODE_SIGN_IDENTITY = "iPhone Developer"; 284 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 285 | GCC_PREFIX_HEADER = "MSCellAccessoryDemo/MSCellAccessoryDemo-Prefix.pch"; 286 | INFOPLIST_FILE = "MSCellAccessoryDemo/MSCellAccessoryDemo-Info.plist"; 287 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 288 | PRODUCT_NAME = "$(TARGET_NAME)"; 289 | TARGETED_DEVICE_FAMILY = 1; 290 | WRAPPER_EXTENSION = app; 291 | }; 292 | name = Debug; 293 | }; 294 | EE12A34117896E2F00DC5124 /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | CODE_SIGN_IDENTITY = "iPhone Developer"; 298 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 299 | GCC_PREFIX_HEADER = "MSCellAccessoryDemo/MSCellAccessoryDemo-Prefix.pch"; 300 | INFOPLIST_FILE = "MSCellAccessoryDemo/MSCellAccessoryDemo-Info.plist"; 301 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | TARGETED_DEVICE_FAMILY = 1; 304 | WRAPPER_EXTENSION = app; 305 | }; 306 | name = Release; 307 | }; 308 | /* End XCBuildConfiguration section */ 309 | 310 | /* Begin XCConfigurationList section */ 311 | EE12A31717896E2F00DC5124 /* Build configuration list for PBXProject "MSCellAccessoryDemo" */ = { 312 | isa = XCConfigurationList; 313 | buildConfigurations = ( 314 | EE12A33D17896E2F00DC5124 /* Debug */, 315 | EE12A33E17896E2F00DC5124 /* Release */, 316 | ); 317 | defaultConfigurationIsVisible = 0; 318 | defaultConfigurationName = Release; 319 | }; 320 | EE12A33F17896E2F00DC5124 /* Build configuration list for PBXNativeTarget "MSCellAccessoryDemo" */ = { 321 | isa = XCConfigurationList; 322 | buildConfigurations = ( 323 | EE12A34017896E2F00DC5124 /* Debug */, 324 | EE12A34117896E2F00DC5124 /* Release */, 325 | ); 326 | defaultConfigurationIsVisible = 0; 327 | defaultConfigurationName = Release; 328 | }; 329 | /* End XCConfigurationList section */ 330 | }; 331 | rootObject = EE12A31417896E2F00DC5124 /* Project object */; 332 | } 333 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MSCellAccessoryDemo 4 | // 5 | // Created by SHIM MIN SEOK on 13. 6. 19.. 6 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class TBViewController; 12 | 13 | @interface AppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) TBViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MSCellAccessoryDemo 4 | // 5 | // Created by SHIM MIN SEOK on 13. 6. 19.. 6 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | #import "TBViewController.h" 12 | 13 | @implementation AppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | self.viewController = [[TBViewController alloc] initWithNibName:@"TBViewController" bundle:nil]; 20 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application 43 | { 44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmapdata/MSCellAccessory/d9ec0b24500f33bd05883a1a6b37c664d3c5e91c/MSCellAccessoryDemo/Default-568h@2x.png -------------------------------------------------------------------------------- /MSCellAccessoryDemo/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmapdata/MSCellAccessory/d9ec0b24500f33bd05883a1a6b37c664d3c5e91c/MSCellAccessoryDemo/Default.png -------------------------------------------------------------------------------- /MSCellAccessoryDemo/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmapdata/MSCellAccessory/d9ec0b24500f33bd05883a1a6b37c664d3c5e91c/MSCellAccessoryDemo/Default@2x.png -------------------------------------------------------------------------------- /MSCellAccessoryDemo/MSCellAccessoryDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/MSCellAccessoryDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MSCellAccessoryDemo' target in the 'MSCellAccessoryDemo' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/ScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmapdata/MSCellAccessory/d9ec0b24500f33bd05883a1a6b37c664d3c5e91c/MSCellAccessoryDemo/ScreenShot.png -------------------------------------------------------------------------------- /MSCellAccessoryDemo/ScreenShot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmapdata/MSCellAccessory/d9ec0b24500f33bd05883a1a6b37c664d3c5e91c/MSCellAccessoryDemo/ScreenShot2.png -------------------------------------------------------------------------------- /MSCellAccessoryDemo/ScreenShot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitmapdata/MSCellAccessory/d9ec0b24500f33bd05883a1a6b37c664d3c5e91c/MSCellAccessoryDemo/ScreenShot3.png -------------------------------------------------------------------------------- /MSCellAccessoryDemo/TBViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBViewController.h 3 | // MSCellAccessoryDemo 4 | // 5 | // Created by SHIM MIN SEOK on 13. 6. 19.. 6 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TBViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/TBViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBViewController.m 3 | // MSCellAccessoryDemo 4 | // 5 | // Created by SHIM MIN SEOK on 13. 6. 19.. 6 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 7 | // 8 | 9 | #import "TBViewController.h" 10 | #import "MSCellAccessory.h" 11 | 12 | @interface TBViewController () 13 | { 14 | NSIndexPath *_selectedIndex; 15 | } 16 | @end 17 | 18 | @implementation TBViewController 19 | 20 | - (id)initWithStyle:(UITableViewStyle)style 21 | { 22 | self = [super initWithStyle:style]; 23 | if (self) { 24 | } 25 | return self; 26 | } 27 | 28 | - (void)viewDidLoad 29 | { 30 | [super viewDidLoad]; 31 | } 32 | 33 | - (void)didReceiveMemoryWarning 34 | { 35 | [super didReceiveMemoryWarning]; 36 | } 37 | 38 | #pragma mark - Table view data source 39 | 40 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 41 | { 42 | return 1; 43 | } 44 | 45 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 46 | { 47 | return 11; 48 | } 49 | 50 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 51 | { 52 | static NSString *CellIdentifier = @"Cell"; 53 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 54 | if (cell == nil) 55 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 56 | 57 | cell.textLabel.font = [UIFont systemFontOfSize:10.0]; 58 | 59 | // [self configureCell:cell indexPath:indexPath accessoryType:NONE]; 60 | // [self configureCell:cell indexPath:indexPath accessoryType:FLAT_PLUS_INDICATOR]; 61 | [self configureCell:cell indexPath:indexPath accessoryType:FLAT_DETAIL_BUTTON]; 62 | // [self configureCell:cell indexPath:indexPath accessoryType:FLAT_DISCLOSURE_INDICATOR]; 63 | // [self configureCell:cell indexPath:indexPath accessoryType:FLAT_CHECKMARK]; 64 | // [self configureCell:cell indexPath:indexPath accessoryType:FLAT_UNFOLD_INDICATOR]; 65 | // [self configureCell:cell indexPath:indexPath accessoryType:FLAT_FOLD_INDICATOR]; 66 | // [self configureCell:cell indexPath:indexPath accessoryType:MSCellAccessoryTypeDetailDisclosure]; 67 | // [self configureCell:cell indexPath:indexPath accessoryType:DISCLOSURE_INDICATOR]; 68 | // [self configureCell:cell indexPath:indexPath accessoryType:CHECKMARK]; 69 | // [self configureCell:cell indexPath:indexPath accessoryType:UNFOLD_INDICATOR]; 70 | // [self configureCell:cell indexPath:indexPath accessoryType:FOLD_INDICATOR]; 71 | 72 | return cell; 73 | } 74 | 75 | - (void)configureCell:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath accessoryType:(MSCellAccessoryType )accessoryType 76 | { 77 | if(accessoryType == FLAT_DETAIL_DISCLOSURE) 78 | { 79 | if(indexPath.row == 0) 80 | { 81 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:255/255.0 green:17/255.0 blue:95/255.0 alpha:1.0], [UIColor colorWithWhite:0.9 alpha:1.0]]]; 82 | } 83 | else if(indexPath.row == 1) 84 | { 85 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:208/255.0 green:44/255.0 blue:55/255.0 alpha:1.0], [UIColor colorWithWhite:0.8 alpha:1.0]]]; 86 | } 87 | else if(indexPath.row == 2) 88 | { 89 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:245/255.0 green:142/255.0 blue:4/255.0 alpha:1.0], [UIColor colorWithWhite:0.7 alpha:1.0]]]; 90 | } 91 | else if(indexPath.row == 3) 92 | { 93 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:230/255.0 green:241/255.0 blue:5/255.0 alpha:1.0], [UIColor colorWithWhite:0.6 alpha:1.0]]]; 94 | } 95 | else if(indexPath.row == 4) 96 | { 97 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:202/255.0 green:190/255.0 blue:1/255.0 alpha:1.0], [UIColor colorWithWhite:0.5 alpha:1.0]]]; 98 | } 99 | else if(indexPath.row == 5) 100 | { 101 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:140/255.0 green:255/255.0 blue:39/255.0 alpha:1.0], [UIColor colorWithWhite:0.4 alpha:1.0]]]; 102 | } 103 | else if(indexPath.row == 6) 104 | { 105 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:20/255.0 green:155/255.0 blue:55/255.0 alpha:1.0], [UIColor colorWithWhite:0.3 alpha:1.0]]]; 106 | } 107 | else if(indexPath.row == 7) 108 | { 109 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:0/255.0 green:170/255.0 blue:255/255.0 alpha:1.0], [UIColor colorWithWhite:0.2 alpha:1.0]]]; 110 | } 111 | else if(indexPath.row == 8) 112 | { 113 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:36/255.0 green:95/255.0 blue:222/255.0 alpha:1.0], [UIColor colorWithWhite:0.1 alpha:1.0]]]; 114 | } 115 | else if(indexPath.row == 9) 116 | { 117 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[[UIColor colorWithRed:90/255.0 green:43/255.0 blue:172/255.0 alpha:1.0], [UIColor colorWithWhite:0. alpha:1.0]]]; 118 | } 119 | else if(indexPath.row == 10) 120 | { 121 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType colors:@[FLAT_DETAIL_BUTTON_DEFAULT_COLOR, FLAT_DISCLOSURE_INDICATOR_DEFAULT_COLOR]]; 122 | } 123 | } 124 | else 125 | { 126 | if(indexPath.row == 0) 127 | { 128 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:255/255.0 green:17/255.0 blue:95/255.0 alpha:1.0]]; 129 | } 130 | else if(indexPath.row == 1) 131 | { 132 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:255/255.0 green:59/255.0 blue:48/255.0 alpha:1.0]]; 133 | } 134 | else if(indexPath.row == 2) 135 | { 136 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:245/255.0 green:142/255.0 blue:4/255.0 alpha:1.0]]; 137 | } 138 | else if(indexPath.row == 3) 139 | { 140 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:230/255.0 green:241/255.0 blue:5/255.0 alpha:1.0]]; 141 | } 142 | else if(indexPath.row == 4) 143 | { 144 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:202/255.0 green:190/255.0 blue:1/255.0 alpha:1.0]]; 145 | } 146 | else if(indexPath.row == 5) 147 | { 148 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:76/255.0 green:217/255.0 blue:100/255.0 alpha:1.0]]; 149 | } 150 | else if(indexPath.row == 6) 151 | { 152 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:55/255.0 alpha:1.0]]; 153 | } 154 | else if(indexPath.row == 7) 155 | { 156 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:0/255.0 green:170/255.0 blue:255/255.0 alpha:1.0]]; 157 | } 158 | else if(indexPath.row == 8) 159 | { 160 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:36/255.0 green:95/255.0 blue:222/255.0 alpha:1.0]]; 161 | } 162 | else if(indexPath.row == 9) 163 | { 164 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:90/255.0 green:43/255.0 blue:172/255.0 alpha:1.0]]; 165 | } 166 | else if(indexPath.row == 10) 167 | { 168 | cell.accessoryView = [MSCellAccessory accessoryWithType:accessoryType color:[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1.0]]; 169 | } 170 | } 171 | } 172 | 173 | - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 174 | { 175 | cell.backgroundColor = [UIColor whiteColor]; 176 | } 177 | 178 | #pragma mark - Table view delegate 179 | 180 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 181 | { 182 | [tableView deselectRowAtIndexPath:indexPath animated:NO]; 183 | 184 | _selectedIndex = indexPath; 185 | 186 | MSCellAccessory *acc = (MSCellAccessory *)[tableView cellForRowAtIndexPath:indexPath].accessoryView; 187 | 188 | NSLog(@"didSelectRowAtIndexPath:%@ type:%d", indexPath, acc.accType); 189 | 190 | [tableView reloadRowsAtIndexPaths:[tableView indexPathsForSelectedRows] withRowAnimation:UITableViewRowAnimationBottom]; 191 | } 192 | 193 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 194 | { 195 | /* 196 | if(indexPath.row == _selectedIndex.row) 197 | return 100; 198 | */ 199 | 200 | return tableView.rowHeight; 201 | } 202 | 203 | - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath 204 | { 205 | MSCellAccessory *acc = (MSCellAccessory *)[tableView cellForRowAtIndexPath:indexPath].accessoryView; 206 | 207 | NSLog(@"accessoryButtonTappedForRowWithIndexPath:%@, type:%d", indexPath, acc.accType); 208 | } 209 | 210 | @end -------------------------------------------------------------------------------- /MSCellAccessoryDemo/TBViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /MSCellAccessoryDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MSCellAccessoryDemo 4 | // 5 | // Created by SHIM MIN SEOK on 13. 6. 19.. 6 | // Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MSCellAccessory 2 | ============ 3 | 4 | [![Version](https://cocoapod-badges.herokuapp.com/v/MSCellAccessory/badge.png)](https://cocoapod-badges.herokuapp.com/v/MSCellAccessory/badge.png) 5 | [![Platform](https://cocoapod-badges.herokuapp.com/p/MSCellAccessory/badge.png)](https://cocoapod-badges.herokuapp.com/p/MSCellAccessory/badge.png) 6 | 7 | 8 | MSCellAccessory is a UITableViewCell accessoryType can easily customizing the colors. Many developer really want to customizing UITableViewCell accessoryType color. but, they using a customized png image are solved. but this method is not good. because Unnecessary to create an image file, and each would have to create all colors. and Loading it unnecessarily increases the capacity of the memory. If using a this library is more easily customizing accessoryType and more flexible via Programmatically. 9 | 10 | #### iOS7 Flat Design 11 | 12 | FLAT_DETAIL_DISCLOSURE: identical to iOS7 UITableViewCellAccessoryDetailDisclosureButton 13 | 14 | FLAT_DETAIL_BUTTON: identical to iOS7 UITableViewCellAccessoryDetailButton 15 | 16 | FLAT_DISCLOSURE_INDICATOR: identical to iOS7 UITableViewCellAccessoryDisclosureIndicator 17 | 18 | FLAT_CHECKMARK: identical to iOS7 UITableViewCellAccessoryCheckmark 19 | 20 | FLAT_UNFOLD_INDICATOR: Flat unfold indicator 21 | 22 | FLAT_FOLD_INDICATOR: Flat fold indicator 23 | 24 | FLAT_PLUS_INDICATOR: Flat plus indicator 25 | 26 | FLAT_MINUS_INDICATOR: Flat minus indicator 27 | 28 | #### Prior to iOS7 29 | 30 | DETAIL_DISCLOSURE: identical to UITableViewCellAccessoryDetailDisclosureButton 31 | 32 | DISCLOSURE_INDICATOR: identical to UITableViewCellAccessoryDisclosureIndicator 33 | 34 | CHECKMARK: identical to UITableViewCellAccessoryCheckmark 35 | 36 | UNFOLD_INDICATOR: Unfold indicator 37 | 38 | FOLD_INDICATOR: Fold indicator 39 | 40 | PLUS_INDICATOR: Plus indicator 41 | 42 | MINUS_INDICATOR: Minus indicator 43 | 44 |

45 | 46 |

47 |

48 | 49 |

50 |

51 | 52 |

53 | 54 | ## Installation ## 55 | 56 | MSCellAccessory is possible via CocoaPods. Just add the following to your Podfile. => `#import ` 57 | 58 | platform :ios 59 | pod 'MSCellAccessory' 60 | 61 | Another way to, drag the included MSCellAccessory folder into your project. => `#import "MSCellAccessory.h"` 62 | 63 | ## Usage ## 64 | 65 | Requirements: At least iOS5 66 | 67 | These classes was written under the ARC. Be sure to specify `-fobjc-arc` the 'Compile Sources' Build Phase for each file if you aren't using ARC project-wide 68 | 69 | ## Sample Code ## 70 | 71 | #import "MSCellAccessory.h" 72 | 73 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 74 | { 75 | static NSString *CellIdentifier = @"Cell"; 76 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 77 | if (cell == nil) 78 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 79 | 80 | if(indexPath.row == 0) 81 | { 82 | cell.accessoryView = [MSCellAccessory accessoryWithType:FLAT_DETAIL_DISCLOSURE colors:@[[UIColor colorWithRed:253/255.0 green:184/255.0 blue:0/255.0 alpha:1.0], [UIColor colorWithWhite:0.5 alpha:1.0]]]; 83 | } 84 | else if(indexPath.row == 1) 85 | { 86 | cell.accessoryView = [MSCellAccessory accessoryWithType:FLAT_DETAIL_BUTTON color:[UIColor colorWithRed:132/255.0 green:100/255.0 blue:159/255.0 alpha:1.0]]; 87 | } 88 | else if(indexPath.row == 2) 89 | { 90 | cell.accessoryView = [MSCellAccessory accessoryWithType:FLAT_DISCLOSURE_INDICATOR color:[UIColor colorWithRed:0/255.0 green:166/255.0 blue:149/255.0 alpha:1.0]]; 91 | } 92 | else if(indexPath.row == 3) 93 | { 94 | cell.accessoryView = [MSCellAccessory accessoryWithType:FLAT_CHECKMARK color:[UIColor colorWithRed:0/255.0 green:123/255.0 blue:170/255.0 alpha:1.0]]; 95 | } 96 | else if(indexPath.row == 4) 97 | { 98 | cell.accessoryView = [MSCellAccessory accessoryWithType:FLAT_UNFOLD_INDICATOR color:[UIColor colorWithRed:0/255.0 green:123/255.0 blue:170/255.0 alpha:1.0]]; 99 | } 100 | else if(indexPath.row == 5) 101 | { 102 | cell.accessoryView = [MSCellAccessory accessoryWithType:FLAT_FOLD_INDICATOR color:[UIColor colorWithRed:0/255.0 green:123/255.0 blue:170/255.0 alpha:1.0]]; 103 | } 104 | 105 | return cell; 106 | } 107 | 108 | ## Release notes ### 109 | 110 | #### Ver 1.1.3 111 | * Rename AccessoryType to MSCellAccessoryType 112 | * Add FLAT_PLUS_INDICATOR, FLAT_MINUS_INDICATOR, PLUS_INDICATOR, MINUS_INDICATOR 113 | 114 | #### Ver 1.1.2 115 | * Discontinued TOGGLE_INDICATOR and change to UNFOLD_INDICATOR, FOLD_INDICATOR. flat also changed. 116 | * Solved what if you change a UITableViewCell height, accessoryView this will affect change the right margin. ( #issue prior to iOS7 ) 117 | * Modified accessoryView frame, divided separately Plain Style and Grouped Style. ( #issue prior to iOS7 ) 118 | 119 | #### Ver 1.1.1 120 | * FLAT_DETAIL_DISCLOSURE, FLAT_DETAIL_BUTTON, DETAIL_DISCLOSURE types auto linking to `- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath` delegate method. when such types accessory touched is called. same as Apple. 121 | * DETAIL_DISCLOSURE size and design modified. 122 | 123 | #### Ver 1.1.0 124 | * Supported iOS7 Flat Design. 125 | 126 | #### Ver 1.0.1 127 | * Bug fixed. 128 | * Modified more similar to the shape of the accessoryType. 129 | 130 | #### Ver 1.0.0 131 | * Initial commit 132 | 133 | ## License ## 134 | 135 | Software License Agreement (BSD License) 136 | 137 | Copyright (c) 2013 SHIM MIN SEOK. All rights reserved. 138 | 139 | Redistribution and use in source and binary forms, with or without 140 | modification, are permitted provided that the following conditions are met: 141 | 142 | 1. Redistributions of source code must retain the above copyright 143 | notice, this list of conditions and the following disclaimer. 144 | 145 | 2. Redistributions in binary form must reproduce the above copyright 146 | notice, this list of conditions and the following disclaimer in 147 | the documentation and/or other materials provided with the 148 | distribution. 149 | 150 | 3. Neither the name of Infrae nor the names of its contributors may 151 | be used to endorse or promote products derived from this software 152 | without specific prior written permission. 153 | 154 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 155 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 156 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 157 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INFRAE OR 158 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 159 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 160 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 161 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 162 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 163 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 164 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 165 | 166 | ## Contact ## 167 | 168 | bitmapdata.com@gmail.com 169 | --------------------------------------------------------------------------------