【问题标题】:rightBarButtonItem.enabled removes my custom layer from the uinavigationbarrightBarButtonItem.enabled 从 uinavigationbar 中删除我的自定义层
【发布时间】:2011-02-05 11:37:55
【问题描述】:

我已经自定义了我的自定义 UINavigationBar 以显示自定义图像(实际上我在 NSTimer 上的许多图像之间交叉淡入淡出):

- (void) displayImage:(EGOImageView*)anImageView {
    CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:@"contents"];
    crossFade.duration = 0.5;
    crossFade.fromValue = self.layer.contents;
    crossFade.toValue = (id)[self imageFromView:anImageView].CGImage;
    [self.layer addAnimation:crossFade forKey:@"animateContents"];
    self.layer.contents = (id)[self imageFromView:anImageView].CGImage;
}

如何防止导航栏在启用或禁用 barButtonItem 时松开我的自定义层?在我的 VC 中执行以下行后,我的导航栏会回到默认状态:

self.navigationItem.rightBarButtonItem.enabled = !editing;

(它恢复到我在 VC 的 viewDidLoad 中设置的 UIBarStyleBlackOpaque)

【问题讨论】:

    标签: iphone uinavigationbar uibarbuttonitem layer rightbarbuttonitem


    【解决方案1】:

    当我在定制 NavBar 时,我发现这很有用 How do iPhone apps Instagram/Reeder/DailyBooth implement custom NavigationBars with variable width back buttons?

    它讲述了如何制作自定义导航栏,然后讨论了过去的一篇文章,即将制作自定义后退按钮。这是一个完整的帖子,可以找到here。我个人发现这些在我当前的项目中很有用。希望这可以解释为什么您的方法会发生这种情况,或者如果您找不到当前使用 crossFade 和 NSTimer 的方法的解决方案,则可以为您提供替代方法

    【讨论】:

    • 谢谢。我需要做的就是在我的 drawRect 中绘制传入的图像。
    猜你喜欢
    • 1970-01-01
    • 2020-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-08
    • 1970-01-01
    • 2011-10-30
    • 1970-01-01
    相关资源
    最近更新 更多