Tag: 使用

closures自适应popup窗口button

在故事板中,我有一个带有button的根视图控制器,触发一个包含UITableViewController的UINavigationController的“呈现为popup窗口”。 我希望导航控制器在iPhone和iPad上均可使用。 在iPad上,这个function非常出色。 在iPhone上,我得到了模态演示文稿,所以现在我需要一个额外的栏button项目来消除模态视图。 从观看WWDCvideo,我已经在根视图控制器中尝试了以下内容: – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { UIViewController *vc = segue.destinationViewController; vc.popoverPresentationController.delegate = self; } – (void)dismissPopover { [self dismissViewControllerAnimated:YES completion:nil]; } – (UIViewController *)presentationController:(UIPresentationController *)controller viewControllerForAdaptivePresentationStyle:(UIModalPresentationStyle)style { UINavigationController *nvc = (UINavigationController *)controller.presentedViewController; UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(dismissPopover)]; nvc.topViewController.navigationItem.leftBarButtonItem = bbi; return nvc; } 我知道-presentationController:viewControllerForAdaptivePresentationStyle:方法应该只在UI自适应,即模态时被调用,但是它根本不会被调用,即使在iPhone上作为模式运行时也是如此。

如何获取未呈现的UIView的快照?

我使用这个方法拍摄快照: UIView *snapshotView = [someView snapshotAfterScreenUpdates:NO]; 这给了我一个UIView,我可以玩。 但是,我需要它的UIImage而不是UIView。 这是我用于将UIView转换为UIImage的方法: – (UIImage *)snapshotOfView:(UIView *)view { UIImage *snapshot; UIGraphicsBeginImageContext(view.frame.size); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; snapshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return snapshot; } 它不起作用,快照是一个空白的UIImage因为snapshotView没有呈现。 显而易见的事情是直接拍摄视图的快照,而不是以UIView的forms拍摄快照,然后转换它。 显而易见的方法的问题是,我使用的WKWebView有一个巨大的错误,不允许你截图。 这是真的,我甚至报告了错误,他们对我说,他们正在试图解决这个问题。 那么,我怎样才能把snapshotView的快照(UIImage)不渲染呢?

圆angularUIView的顶部和添加边框

我在下面的代码中做了四舍五入的分类。 我也想画一个边框。 但边angular在angular落的圆angular部分没有显示。 这是代码 – (void) roundTopCorners:(CGFloat) radius { self.layer.masksToBounds = YES; CGRect bounds = self.bounds; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(radius, radius)]; CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = bounds; maskLayer.path = maskPath.CGPath; maskLayer.strokeColor = [UIColor redColor].CGColor; self.layer.mask = maskLayer; }