测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最新发布 | 2014年12月 |
由Maksym Grebenets--dscription=cba-macbook-pro维护。
为 iOS 定制的 UIPopoverController
背景视图。实现了 iOS 开发者文档中描述的 UIPopoverBackgroundView
的自定义子类
调用 MBPopoverViewBackground
类的 initialize
方法来完成此类及其所有子类所需的初始化。在应用启动时调用此方法一次。
通过调用 setArrowImageName:
和 setBackgroundImageName:
设置您自定义的箭头和背景图像。
通过调用 setBackgroundImageCapInsets:
设置用于拉伸背景图像的自定义帽形缩进。
使用 setContentViewInsets:
方法定义从内容视图边缘到背景视图边缘的缩进。
// Blue popover
@interface MBPopoverBackgroundViewBlue : MBPopoverBackgroundView
@end
// When the app launches
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Initialize
[MBPopoverBackgroundView initialize];
// Red popover with arrow
[MBPopoverBackgroundView setArrowImageName:@"popover-arrow-red.png"];
[MBPopoverBackgroundView setBackgroundImageName:@"popover-background-red.png"];
[MBPopoverBackgroundView setBackgroundImageCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
[MBPopoverBackgroundView setContentViewInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
// Blue popover with custom call-out instead of arrow
[MBPopoverBackgroundViewBlue setArrowImageName:@"popover-callout-dotted-blue.png"];
[MBPopoverBackgroundViewBlue setBackgroundImageName:@"popover-background-blue.png"];
[MBPopoverBackgroundViewBlue setBackgroundImageCapInsets:UIEdgeInsetsMake(15, 15, 15, 15)];
[MBPopoverBackgroundViewBlue setContentViewInsets:UIEdgeInsetsMake(20, 20, 20, 20)];
// ***
}
// When creating popover in the app
{
UIPopoverController *popoverCtl = ...;
popoverCtl.popoverBackgroundViewClass = [MBPopoverBackgroundView class]; // red
popoverCtl.popoverBackgroundViewClass = [MBPopoverBackgroundViewBlue class]; // or blue
// ***
}