AlertView.m 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // AlertView.m
  3. // HuaweiMeeting
  4. //
  5. // Created by imac on 12-10-15.
  6. // Copyright (c) 2012年 Twin-Fish. All rights reserved.
  7. //
  8. #import "AlertView.h"
  9. #import "UIFactory.h"
  10. #import "QuartzCore/QuartzCore.h"
  11. @implementation AlertView
  12. @synthesize temp_delegate;
  13. - (id)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. // Initialization code
  18. }
  19. return self;
  20. }
  21. /*
  22. // Only override drawRect: if you perform custom drawing.
  23. // An empty implementation adversely affects performance during animation.
  24. - (void)drawRect:(CGRect)rect
  25. {
  26. // Drawing code
  27. }
  28. */
  29. - (void)show
  30. {
  31. temp_delegate = self.delegate;
  32. self.delegate = self;
  33. [super show];
  34. }
  35. //- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
  36. //{
  37. // [super dismissWithClickedButtonIndex:buttonIndex animated:NO];
  38. // [[self class] setAnimationsEnabled:YES];
  39. //}
  40. - (void)willPresentAlertView:(UIAlertView *)alertView
  41. {
  42. for (UIView *view in self.subviews) {
  43. if ([view isKindOfClass:[UIImageView class]]) {
  44. [view.layer setCornerRadius:8];
  45. [view.layer setMasksToBounds:YES];
  46. ((UIImageView *)view).image = nil;
  47. [view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"com_repeat_paper"]]];
  48. } else if ([view isKindOfClass:[UIButton class]]) {
  49. CGFloat buttonHeight = [[UIDevice currentDevice].model hasPrefix:@"iPad"] ? 33.0f : 33.0f;
  50. CGFloat buttonWidth = 135.0f;
  51. CGRect buttonFrame = view.frame;
  52. buttonFrame.origin.y += CGRectGetHeight(buttonFrame) - buttonHeight;
  53. buttonFrame.size.height = buttonHeight;
  54. buttonFrame.origin.x += (CGRectGetWidth(buttonFrame) - buttonWidth) / 2.0f;
  55. buttonFrame.size.width = buttonWidth;
  56. view.frame = buttonFrame;
  57. UIImage *normalImage = [UIFactory resizableImageWithSize:CGSizeMake(4.0f, 0.0f) image:[UIImage imageNamed:@"com_button1_normal"]];
  58. UIImage *clickImage = [UIFactory resizableImageWithSize:CGSizeMake(4.0f, 0.0f) image:[UIImage imageNamed:@"com_button1_click"]];
  59. [((UIButton *)view) setBackgroundImage:normalImage forState:UIControlStateNormal];
  60. [((UIButton *)view) setBackgroundImage:clickImage forState:UIControlStateHighlighted];
  61. [((UIButton *)view).titleLabel setFont:[UIFont systemFontOfSize:16]];
  62. [((UIButton *)view) setTitleShadowColor:[UIColor clearColor] forState:UIControlStateNormal];
  63. [((UIButton *)view) setTitleShadowColor:[UIColor clearColor] forState:UIControlStateHighlighted];
  64. [((UIButton *)view) setTitleColor:[UIColor colorWithRed:82.0/255 green:30.0/255 blue:4.0/255 alpha:1.0]
  65. forState:UIControlStateNormal];
  66. [((UIButton *)view) setTitleColor:[UIColor colorWithRed:82.0/255 green:30.0/255 blue:4.0/255 alpha:1.0]
  67. forState:UIControlStateHighlighted];
  68. } else if ([view isKindOfClass:[UILabel class]]) {
  69. ((UILabel *)view).textColor = [UIColor blackColor];
  70. ((UILabel *)view).shadowColor = [UIColor clearColor];
  71. }
  72. }
  73. self.delegate = temp_delegate;
  74. }
  75. @end