Life would be so much simple if we don't care so much

Archive for the ‘iOS’ Category

How To Customize Checkmark Cell

We have 3 ways:
1. Use default
ex: cell.accessoryType = UITableViewCellAccessoryCheckmark;

2. Use image view

_ create image view
self.checkmark = [[UIImageViewalloc] initWithImage:[UIImageimageNamed:@”checkmark.png”]];
[self.checkmark setFrameSize:CGSizeMake(15.0f, 15.0f)];
[self.checkmark setFrameOriginX:50.0];
_ create add it to cell in method:
– (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
[cell addSubview:self.snoozeCheckmark];


3. Use some text-code of default checkmark/icon


@”\u2611″, @”\u2B1C”, @”\u2705″, @”\u26AB”, @”\u26AA”, @”\u2714″, @”\U0001F44D”, @”\U0001F44E”

In the method, we can use it like this:

– (UITableViewCell*) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.textLabel.text = @”Vibration \u2B1C”;
cell.textLabel.text = @”Vibration \u2705″;


How To Set Gradient For UIView

First, remember to import class framework package

#import <QuartzCore/QuartzCore.h>

Then add this:

UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];

[view.layer insertSublayer:gradient atIndex:0];