iToast.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // iToast.h
  3. // iToast
  4. //
  5. // Created by Diallo Mamadou Bobo on 2/10/11.
  6. // Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif /* __cplusplus */
  13. typedef enum iToastGravity {
  14. iToastGravityTop = 1000001,
  15. iToastGravityBottom,
  16. iToastGravityCenter
  17. } iToastGravity;
  18. typedef enum iToastDuration {
  19. iToastDurationLong = 10000,
  20. iToastDurationShort = 1000,
  21. iToastDurationNormal = 3000
  22. } iToastDuration;
  23. typedef enum iToastType {
  24. iToastTypeInfo = -100000,
  25. iToastTypeNotice,
  26. iToastTypeWarning,
  27. iToastTypeError
  28. } iToastType;
  29. @class iToastSettings;
  30. @interface iToast : NSObject {
  31. iToastSettings *_settings;
  32. NSInteger offsetLeft;
  33. NSInteger offsetTop;
  34. NSTimer *timer;
  35. UIView *view;
  36. NSString *text;
  37. NSAttributedString *attartext;
  38. /**
  39. * @brief 标记是否使用富文本
  40. */
  41. BOOL useAttr;
  42. }
  43. - (void)show;
  44. - (iToast *)setDuration:(NSInteger)duration;
  45. - (iToast *)setGravity:(iToastGravity) gravity offsetLeft:(NSInteger)left offsetTop:(NSInteger)top;
  46. - (iToast *)setGravity:(iToastGravity)gravity;
  47. - (iToast *)setPostion:(CGPoint) position;
  48. + (iToast *)makeText:(NSString *)text;
  49. + (iToast *)makeAttrText:(NSAttributedString *)_attrtext;
  50. - (iToastSettings *)theSettings;
  51. @end
  52. @interface iToastSettings : NSObject<NSCopying>{
  53. NSInteger duration;
  54. iToastGravity gravity;
  55. CGPoint postition;
  56. iToastType toastType;
  57. NSDictionary *images;
  58. BOOL positionIsSet;
  59. }
  60. @property (assign) NSInteger duration;
  61. @property (assign) iToastGravity gravity;
  62. @property (assign) CGPoint postition;
  63. @property (readonly) NSDictionary *images;
  64. - (void)setImage:(UIImage *)img forType:(iToastType) type;
  65. + (iToastSettings *) getSharedSettings;
  66. @end
  67. #ifdef __cplusplus
  68. }
  69. #endif /* __cplusplus */