Tag: 客观地

bezierPathWithRoundedRect不是完美的圈子

我画圈有一些问题: 这个简单的代码表明: – (void)drawRect:(CGRect)rect { self.layer.sublayers = nil; CGFloat radius = self.frame.size.width/2; circle = [CAShapeLayer layer]; circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.width) cornerRadius:radius].CGPath; circle.fillColor = [UIColor clearColor].CGColor; circle.strokeColor = [UIColor redColor].CGColor; circle.lineWidth = 4; [self.layer addSublayer:circle]; CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; drawAnimation.duration = 1.0; // "animate over 10 seconds or so.." drawAnimation.repeatCount = 1.0; […]

获取由UIView的animateWithDuration创build的animation的参考或通过任何其他方式识别它

假设我制作了这样一个animation: [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ someView.frame = CGRect(0, 100, 200, 200); } completion:nil]; 假设我在someView中有子视图,它们的layoutSubviews方法被覆盖。 我想识别该布局中正在进行的animation,并根据我检测到的animation是由我创build的,还是例如由设备旋转导致的animation来做出相应的动作。 为了使animation进行中,我使用下面的代码: for (NSString *animationKey in [self.layer animationKeys]) { CAAnimation *animation = [self.layer animationForKey:animationKey]; // … Do something … } 现在如果我将使用CABasicAnimation,我可以设置任意属性使用: [myAnimation setValue:@"mySuperCoolAnimation" forKey:@"AnimationName"]; 然后检查另一侧的钥匙。 但我想避免使用CABasicAnimation,因为我的复杂的视图层次结构。 所以为了简单起见,有没有办法像使用UIView animateWithDuration那样做:

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上作为模式运行时也是如此。