LSMessageHUD 1.0.0

LSMessageHUD 1.0.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年3月

lslin 维护。



  • lslin

为 iOS 设计的容易使用和可定制的消息/通知 HUD,支持简单的字符串或属性字符串。

示例

LSMessageHUD Example1

功能

  • 键盘高度调整。
  • 横竖屏方向调整。
  • 易于定制。

安装

LSMessageHUD 通过 CocoaPods 提供,将以下行添加到您的 Podfile 中

pod 'LSMessageHUD'

要求

需要 iOS 7.0 及以上,ARC。

使用方法

简单消息

  #import "LSMessageHUD.h"

  - (void)onMessageTapped:(id)sender {

    //show without title
    [LSMessageHUD showWithMessage:@"Hello, LSMessageHUD"];

    //show with title    
    [LSMessageHUD showWithMessage:@"Hello, LSMessageHUD" title:@"Test"];
  }

属性消息

  #import "LSMessageHUD.h"

  - (void)onMessageTapped:(id)sender {

    NSMutableAttributedString *attrMsg = [[NSMutableAttributedString alloc] initWithString:@"Do any additional setup after loading the view, typically from a nib."];
    [attrMsg addAttributes:@{NSForegroundColorAttributeName : [UIColor redColor]} range:NSMakeRange(0, 6)];
    [attrMsg addAttributes:@{NSForegroundColorAttributeName : [UIColor greenColor]} range:NSMakeRange(24, 13)];

    NSMutableAttributedString *attrTitle = [[NSMutableAttributedString alloc] initWithString:@"Note"];
    [attrTitle addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:20.0]} range:NSMakeRange(0, attrTitle.length)];

    [LSMessageHUD showWithAttributedMessage:attrMsg title:nil duration:1.5 canBeDismissed:YES];

    [LSMessageHUD showWithAttributedMessage:attrMsg title:attrTitle duration:1.5 canBeDismissed:YES];
  }

可定制

@property (strong, nonatomic) UIFont *defaultTitleFont;              /**< default is systemFont with 16.0 */
@property (strong, nonatomic) UIFont *defaultMessageFont;            /**< default is systemFont with 14.0 */
@property (strong, nonatomic) UIColor *defaultTitleTextColor;        /**< default is white color */
@property (strong, nonatomic) UIColor *defaultMessageTextColor;      /**< default is white color */
@property (strong, nonatomic) UIColor *backgroundColor;              /**< default is RGBA(0, 0, 0, 0.8) */

@property (assign, nonatomic) UIEdgeInsets messageContentInsets;     /**< default is (10, 10, 10, 10) */
@property (assign, nonatomic) CGFloat messageCornerRadius;           /**< default is 6.0 */

@property (assign, nonatomic) CGFloat messageViewVerticalOffsetRate; /**< default is 0.5, vertical center */
@property (assign, nonatomic) NSTimeInterval defaultDuration;        /**< default is 2.0 */