kenjox

IOS Controls

Jan 21st, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Header file
  2.  
  3. @interface CameraViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
  4. {
  5.     UIScrollView *filtersScrollView;
  6. }
  7.  
  8. //Implementation file
  9.  
  10. - (void)viewDidLoad
  11. {
  12.     [super viewDidLoad];
  13.     [self customControl];
  14. }
  15.  
  16. -(void)customControl
  17. {
  18.     filtersScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 400, self.view.bounds.size.width, 90)];
  19.     [filtersScrollView setScrollEnabled:YES];
  20.     [filtersScrollView setShowsVerticalScrollIndicator:NO];
  21.     [filtersScrollView setShowsHorizontalScrollIndicator:NO];
  22.    
  23.     int x = 10;
  24.     //create a new dynamic button
  25.     for (int j=0; j<=10; j++)
  26.     {  
  27.         CGRect frame = CGRectMake(x, 0, 70, 70);
  28.         UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  29.         [button setTag:j];
  30.        
  31.         CALayer *layer = [button layer];
  32.         [layer setCornerRadius:0.0];
  33.         [layer setBorderColor:[[UIColor whiteColor] CGColor]];
  34.         [layer setMasksToBounds:YES];
  35.         [layer setBorderWidth:2.0];
  36.        
  37.         button.frame = frame;
  38.    
  39.         [button addTarget:self action:@selector(filterButton:) forControlEvents:UIControlEventTouchUpInside];
  40.        
  41.         [self.filterScrollview addSubview:button];
  42.         x= x+10;
  43.     }
  44.    
  45.     [filtersScrollView setContentSize:CGSizeMake(400, 100)];
  46.     [self.view addSubview:filtersScrollView];
  47.    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment