No *_*ing 15 uipopovercontroller ios
我用这个好的教程来创建一个自定义的UIPopoverBackgroundView类.
它运作良好.唯一的问题是我没有得到典型的UIPopoverController投影,我想要它.我已经尝试在我的UIPopoverBackgroundView实例层上指定它而没有成功.我的UIPopoverController实例似乎没有公共视图来操作.将其添加到弹出窗口内容也不起作用.
可能非常简单:如何在使用自定义UIPopoverBackgroundView类时添加阴影?
// UIPopoverBackgroundView.m
-(id)initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
_borderImageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"bg-popover.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(CAP_INSET,CAP_INSET,CAP_INSET,CAP_INSET)]];
_arrowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg-popover-arrow.png"]];
[self addSubview:_borderImageView];
[self addSubview:_arrowView];
self.layer.shadowOffset = CGSizeMake(50, 50);
self.layer.shadowColor = [[UIColor blackColor] CGColor];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
Mik*_*rdo 19
您无需添加自己的阴影.基地UIPopoverBackgroundView会为你做.只需确保在您的layoutSubviews实施中调用super .
编辑:我的评论适用于针对iOS 6的应用.
No *_*ing 14
好吧,想通了.我需要添加投影borderImageView,而不是弹出窗口实例的视图.
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
_borderImageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"bg-popover.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(CAP_INSET,CAP_INSET,CAP_INSET,CAP_INSET)]];
_arrowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg-popover-arrow.png"]];
[self addSubview:_borderImageView];
[self addSubview:_arrowView];
_borderImageView.layer.cornerRadius = 5.0f;
_borderImageView.layer.masksToBounds = NO;
_borderImageView.layer.borderWidth = 1.0f;
_borderImageView.layer.borderColor = [UIColor blackColor].CGColor;
_borderImageView.layer.shadowColor = [UIColor blackColor].CGColor;
_borderImageView.layer.shadowOpacity = 0.8;
_borderImageView.layer.shadowRadius = 50;
_borderImageView.layer.shadowOffset = CGSizeMake(-10.0f, 10.0f);
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8133 次 |
| 最近记录: |