Created
July 23, 2018 14:53
-
-
Save CreatureSurvive/9187af2cce0245153a08a4a14415239a to your computer and use it in GitHub Desktop.
Example of a custom PSTableCell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Preferences/PSTableCell.h> | |
| #import <Preferences/PSSpecifier.h> | |
| @interface CSPVersionCell : PSTableCell | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "CSPVersionCell.h" | |
| #import "../Managers/CSPPackageManager.h" | |
| @implementation CSPVersionCell { | |
| NSString *_bundleID; | |
| NSString *_label; | |
| NSString *_version; | |
| } | |
| - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier specifier:(PSSpecifier *)specifier { | |
| self = [super initWithStyle:style reuseIdentifier:reuseIdentifier specifier:specifier]; | |
| _bundleID = [specifier propertyForKey:@"bundleID"]; | |
| _label = [specifier propertyForKey:@"label"] ? : @"Version:"; | |
| _version = _bundleID ? [CSPPackageManager packageVersionForBundleID:_bundleID] : @"missing bundleID"; | |
| self.textLabel.text = _label; | |
| self.detailTextLabel.text = _version; | |
| self.accessoryView.hidden = YES; | |
| self.imageView.hidden = YES; | |
| // [self checkForUpdate]; | |
| return self; | |
| } | |
| - (instancetype)initWithSpecifier:(PSSpecifier *)specifier { | |
| self = [self initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil specifier:specifier]; | |
| return self; | |
| } | |
| - (UIImage *)updateIconOfColor:(UIColor *)color { | |
| CGRect rect = CGRectMake(0, 0, 10, 10); | |
| UIGraphicsBeginImageContext(rect.size); | |
| CGContextRef context = UIGraphicsGetCurrentContext(); | |
| CGContextSetFillColorWithColor(context, [color CGColor]); | |
| CGContextFillRect(context, rect); | |
| UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
| UIGraphicsEndImageContext(); | |
| return image; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment