LTxPopup 0.0.5

LTxPopup 0.0.5

liangtong 维护。



LTxPopup 0.0.5

  • 作者:
  • liangtong

LTxPopup

弹出组件集合。

  • 菜单
  • 吐司
  • 视图
  • 警告

使用 CocoaPods 安装

LTxPopup 可在 CocoaPods 中找到,在您的 Podfile 中指定它

pod 'LTxPopup'

部署

9.0

PopupMenu

UIViewController 分类

只需3步。

  • 设置配置
  • 协议方法
  • 显示

例如。如果您使用 LTxPopupMenu 显示自定义 Nib 菜单项

//step 1 : set up configuration
LTxPopupMenuConfiguration* config = [LTxPopupMenuConfiguration defaultConfiguration];
config.rowHeight = UITableViewAutomaticDimension;
config.menuContentSize = CGSizeMake(360, 200);
config.separatorStyle = UITableViewCellSeparatorStyleNone;
config.cellNib = [UINib nibWithNibName:@"LTxMenuItemTableViewCell" bundle:nil];

//step 2: protocol method
-(NSInteger)ltx_numberOfRows{
    return _dataSource.count;
}
-(void)ltx_configMenuCellItem:(UITableViewCell*)cell forIndex:(NSInteger)index{
   NSDictionary* item = [_dataSource objectAtIndex:index];
   if ([cell isKindOfClass:[LTxMenuItemTableViewCell class]]) {
       LTxMenuItemTableViewCell* nibCell = (LTxMenuItemTableViewCell*)cell;
       nibCell.item = item;
   }
}
-(void)ltx_selectedIndex:(NSInteger)index{
   NSLog(@"%td row is selected",index);
}

//step 3: show
[self showLTxPopupMenuFrom:sender configuration:config delegate:self];

配置

您可以使用 LTxPopupMenuConfiguration 自定义 LTxPopupMenu,包括箭头颜色、方向、内容大小、项高度等。

//arrow color. default is [UIColor whiteColor]
@property (nonatomic, strong) UIColor* arrowColor;

//arrow direction. default is UIPopoverArrowDirectionAny
@property (nonatomic, assign) UIPopoverArrowDirection arrowDirection;

//menu content size. default is CGSizeMake(200, 300)
@property (nonatomic, assign) CGSize menuContentSize;

/**
* menu item height. default is 50.f
* you should set it to UITableViewAutomaticDimension when estimoting row height
**/
@property (nonatomic, assign) CGFloat rowHeight;
/**
* estimoted item height. default is 50.f
**/
@property (nonatomic, assign) CGFloat estimatedRowHeight;
/**
* menu item separator style. default is line
**/
@property (nonatomic, assign) UITableViewCellSeparatorStyle separatorStyle;
/**
* menu item separator line color. default is [UIColor lightGrayColor]
**/
@property (nonatomic, strong) UIColor* separatorColor;
/**
* menu item cell style. default is UITableViewCellStyleDefault
**/
@property (nonatomic, assign) UITableViewCellStyle itemStyle;
/**
* menu scroll indicator. default value is NO.
**/
@property (nonatomic, assign) BOOL showsScrollIndicator;
/**
* when you want to use nib with LTxPopupMenu item.
**/
@property (nonatomic, strong) UINib* cellNib;

/**
* @brief: init method. also you can use alloc and init method.
**/
+(instancetype)defaultConfiguration;

委托

需要委托方法 ltx_numberOfRowsltx_configMenuCellItem:forIndex:

@required
/**
* number of rows in popupMenu
**/
-(NSInteger)ltx_numberOfRows;

/**
* custom menu item at index
**/
-(void)ltx_configMenuCellItem:(UITableViewCell*)cell forIndex:(NSInteger)index;


@optional
/**
* menu item is selected at index
**/
-(void)ltx_selectedIndex:(NSInteger)index;

PopupView

UIViewControllerUIView 分类

设置配置

   LTxPopupViewConfiguration* config = [LTxPopupViewConfiguration defaultConfiguration];
   config.containerBackgroundColor = [[UIColor brownColor] colorWithAlphaComponent:0.2];//outside color
   config.cornerSize = 25.f;//corner size
   config.dismissOnTapOutside = NO;//dismiss on tap outside
   //animation setting
   config.showAnimationType = LTxPopupShowAnimationAppear;
   config.showAnimationDuration = .6f;
   config.hideAnimationType = LTxPopupHideAnimationFadeOut;
   config.hideAnimationDuration = .4f;

显示和隐藏

   //show
   [self.view showLTxPopupView:popView configuration:config];

   //hide. You may not need it if you set dismissOnTapOutside = YES
   [self.view hideLTxPopupView];

PopupToast

LTxPopupToast的快速示例

   LTxPopupToastConfiguration* configuration = [LTxPopupToastConfiguration defaultConfiguration];
   configuration.image = [UIImage imageNamed:@"teal_checkmark"];
   configuration.title = @"Notification";
   configuration.message = @"This liangtong from zhengzhou. thanks very much.   😄 ";
   
   [LTxPopupToast showLTxPopupToastWithConfiguration:configuration show:^{
       NSLog(@"popup toast show complete");
   } tap:^{
       NSLog(@"tap at popup toast ");
   } dismiss:^{
       NSLog(@"popup toast dismissed");
   }];

设置吐司

@interface LTxPopupToastConfiguration : NSObject

/**
* show under status bar
**/
@property (nonatomic, assign) BOOL showUnderStatusBar;

/**
* background color
**/
@property (nonatomic, strong) UIColor* backgroundColor;

/**
* image on the left of toast. nil means no image
**/
@property (nonatomic, strong) UIImage* image;

/**
* ignore btn. title color and font
**/
@property (nonatomic, assign) BOOL showIgnoreBtn;
@property (nonatomic, strong) NSString* ignoreBtnTitle;
@property (nonatomic, strong) UIColor* ignroeBtnTitleColor;
@property (nonatomic, assign) CGFloat ignoreBtnTitleFontSize;

/**
* title
**/
@property (nonatomic, strong) NSString* title;
@property (nonatomic, assign) NSTextAlignment titleTextAlignment;
@property (nonatomic, strong) UIColor* titleColor;
@property (nonatomic, assign) CGFloat titleFontSize;

/**
* message
**/
@property (nonatomic, strong) NSString* message;
@property (nonatomic, assign) NSTextAlignment messageTextAlignment;
@property (nonatomic, strong) UIColor* messageColor;
@property (nonatomic, assign) CGFloat messageFontSize;

/**
* animating
**/
@property (nonatomic, assign) CGFloat showAnimateDuration;
@property (nonatomic, assign) CGFloat showDuration;
@property (nonatomic, assign) BOOL autoDismiss;

/**
* @brief: init method. also you can use alloc and init method.
**/
+(instancetype)defaultConfiguration;
@end

PopupAlert

在上面的 UIAlertController}

   UIAlertAction* cancelAction = ...;
   UIAlertAction* okAction = ...;
   UIAlertAction* desAction = ...;

   [self showLTxPopupAlertWithTitle:@"提醒"
                            message:@"这是一个AlertViewController"
                              style:UIAlertControllerStyleAlert
                         sourceView:nil
                            actions:cancelAction,okAction,desAction,nil];

版本日志

  • 0.0.4 (2018/07/31) - 支持弹出吐司

  • 0.0.3 (2018/07/30) - 支持弹出警告

  • 0.0.2 (2018/07/27) - 支持弹出视图

  • 0.0.1 (2018/07/26) - 支持弹出菜单

联系信息

[email protected]

许可协议

MIT 许可协议

版权所有 (c) 2018 liangtong

以下是对本软件及其关联文档文件(以下简称“软件”)的副本持有者的授予,任何人免费获得此软件和关联文档文件的副本(以下简称“软件”),在未经限制的情况下使用该“软件”,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,以及允许向“软件”供应人员从事此类活动,但以以下条件为前提:

上述版权声明和本许可声明应包含在软件的任何副本或主要部分的软件中。

“软件”按“原样”提供,不提供任何明示或暗示的保证,包括但不限于对适销性、适用于特定用途和不侵权的保证。在任何情况下,任何作者或版权所有者均不对任何主张、赔偿或其他责任负责,无论源自、因涉及或与“软件”或其使用或其他方式有关,包括合同、侵权或其他方式。