为了运行示例项目;首先克隆仓库,然后从 Example 目录运行 pod install
在您的视图控制器中使用它(有样式和按钮)
// set appearance style
[[MMPopLabel appearance] setLabelColor:[UIColor blueColor]];
[[MMPopLabel appearance] setLabelTextColor:[UIColor whiteColor]];
[[MMPopLabel appearance] setLabelTextHighlightColor:[UIColor greenColor]];
[[MMPopLabel appearance] setLabelFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:12.0f]];
[[MMPopLabel appearance] setButtonFont:[UIFont fontWithName:@"HelveticaNeue" size:12.0f]];
// _label is a view controller property
_label = [MMPopLabel popLabelWithText:
@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. "
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s."];
// add a couple of buttons
UIButton *skipButton = [[UIButton alloc] initWithFrame:CGRectZero];
[skipButton setTitle:NSLocalizedString(@"Skip Tutorial", @"Skip Tutorial Button") forState:UIControlStateNormal];
[_label addButton:skipButton];
UIButton *okButton = [[UIButton alloc] initWithFrame:CGRectZero];
[okButton setTitle:NSLocalizedString(@"OK, Got It!", @"Dismiss Button") forState:UIControlStateNormal];
[_label addButton:okButton];
// add it to your view
[self.view addSubview:_label];
要显示标签,只需将以下代码添加到按钮动作或其他类型的事件中,传入您希望指向的视图
- (IBAction)showLabel:(id)sender
{
UIView *view = (UIView *)sender;
[_label popAtView:view];
}
MMPopLabel 现在也支持 UIBarButtonItem
- (IBAction)showLabel:(id)sender
{
UIBarButtonItem *barButtonItem = (UIBarButtonItem *)sender;
[_label popAtBarButtonItem:barButtonItem];
}
要接收标签事件,只需设置您的视图控制器为代理,实现 MMPopLabelDelegate 协议
- (void)dismissedPopLabel:(MMPopLabel *)popLabel;
- (void)didPressButtonForPopLabel:(MMPopLabel *)popLabel atIndex:(NSInteger)index;
要禁用动画,在设置标签时使用以下选项
_label = [MMPopLabel popLabelWithText:
@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. "
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s." options:MMPopLabelAnimationOptionDontPop];
查看 MMPopLabelAnimationOptions 枚举以获取更多选项。
mgcm,[email protected]
MMPopLabel 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。