QuartzFunViewController.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:2k
源码类别:

iPhone

开发平台:

MultiPlatform

  1. //
  2. //  QuartzFunAppDelegate.m
  3. //  QuartzFun
  4. //
  5. //  Created by Jeff LaMarche on 7/31/08.
  6. //  Copyright __MyCompanyName__ 2008. All rights reserved.
  7. //
  8. #import "QuartzFunViewController.h"
  9. #import "QuartzFunView.h"
  10. #import "UIColor-Random.h"
  11. #import "Constants.h"
  12. @implementation QuartzFunViewController
  13. @synthesize colorControl;
  14. - (IBAction)changeColor:(id)sender {
  15. UISegmentedControl *control = sender;
  16. NSInteger index = [control selectedSegmentIndex];
  17. QuartzFunView *quartzView = (QuartzFunView *)self.view;
  18. switch (index) {
  19. case kRedColorTab:
  20. quartzView.currentColor = [UIColor redColor];
  21. quartzView.useRandomColor = NO;
  22. break;
  23. case kBlueColorTab:
  24. quartzView.currentColor = [UIColor blueColor];
  25. quartzView.useRandomColor = NO;
  26. break;
  27. case kYellowColorTab:
  28. quartzView.currentColor = [UIColor yellowColor];
  29. quartzView.useRandomColor = NO;
  30. break;
  31. case kGreenColorTab:
  32. quartzView.currentColor = [UIColor greenColor];
  33. quartzView.useRandomColor = NO;
  34. break;
  35. case kRandomColorTab:
  36. quartzView.useRandomColor = YES;
  37. break;
  38. default:
  39. break;
  40. }
  41. }
  42. - (IBAction)changeShape:(id)sender {
  43. UISegmentedControl *control = sender;
  44. [(QuartzFunView *)self.view setShapeType:[control selectedSegmentIndex]];
  45. if ([control selectedSegmentIndex] == kImageShape)
  46. [colorControl setHidden:YES];
  47. else
  48. [colorControl setHidden:NO];
  49. }
  50. - (void)viewDidLoad {
  51. [super viewDidLoad];
  52. }
  53. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  54. // Return YES for supported orientations
  55. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  56. }
  57. - (void)didReceiveMemoryWarning {
  58. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  59. // Release anything that's not essential, such as cached data
  60. }
  61. - (void)dealloc {
  62. [colorControl release];
  63. [super dealloc];
  64. }
  65. @end