Preview-010
EPISODE #10, 25 Apr 09:00
PrettyKit va vous permettre de créer des applications simples mais dans le détail en quelques lignes de code ! Des UINavigationBar ? Des cellules ? Vous allez être servi !
Duration : 780

Github : https://github.com/vicpenap/PrettyKit

Sources du screencast: https://github.com/jayztemplier/010-PrettyKit

Installation :
  • Copier le dossier PrettyKit dans votre projet
  • Ajouter le framework QuartzCore
  • Mettre le flag "-fno-objc-arc aux fichiers de PrettyKit

ILFirstTableViewController.m

#import "PrettyKit.h"
- (void)viewDidLoad
{
    [super viewDidLoad];
    PrettyNavigationBar *navBar = (PrettyNavigationBar *)self.navigationController.navigationBar;
    navBar.topLineColor = [UIColor colorWithHex:0xFF1000];
    navBar.gradientStartColor = [UIColor colorWithHex:0xDD0000];
    navBar.gradientEndColor = [UIColor colorWithHex:0xAA0000];
navBar.bottomLineColor = [UIColor colorWithHex:0x990000];
navBar.tintColor = navBar.gradientEndColor; self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]; }

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 2; }

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. switch (section) { case 0: return 5; break; case 1: return 1; break; default: break; } return 0; }

- (UITableViewCell )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; static NSString *GridCellIdentifier = @"GridCell"; if (indexPath.section == 1) { PrettySegmentedControlTableViewCell *cell = (PrettySegmentedControlTableViewCell)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) { cell = [[PrettySegmentedControlTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:GridCellIdentifier]; cell.tableViewBackgroundColor = self.tableView.backgroundColor; } [cell setTitles:[NSArray arrayWithObjects:@"1",@"2", @"3", nil]]; [cell prepareForTableView:tableView indexPath:indexPath]; [cell setActionBlock:^(NSIndexPath * aIndexPath, int index) { UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Action" message:[NSString stringWithFormat:@"%d tapped", index] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }]; return cell; } PrettyTableViewCell cell = (PrettyTableViewCell)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) { cell = [[PrettyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.tableViewBackgroundColor = self.tableView.backgroundColor; } [cell.textLabel setText:[NSString stringWithFormat:@"%d - Cool", indexPath.row]]; [cell prepareForTableView:tableView indexPath:indexPath]; return cell; }

blog comments powered by Disqus