objective-c – 如何使用核心动画来动画化NSTextField的背景颜色
发布时间:2020-12-16 05:42:34 所属栏目:百科 来源:网络整理
导读:我试图使用核心动画来突出显示一个文本字段是无效的. [[my_field animator] setBackgroundColor [NSColor yellowColor]] 更新字段背景颜色,但不会更改动画.更新属性,如字段的位置适当地动画.我假设这是因为NSAnimatablePropertyContainer搜索中没有包含背景
我试图使用核心动画来突出显示一个文本字段是无效的.
[[my_field animator] setBackgroundColor [NSColor yellowColor]] 更新字段背景颜色,但不会更改动画.更新属性,如字段的位置适当地动画.我假设这是因为NSAnimatablePropertyContainer搜索中没有包含背景颜色. 我也试图明确地创建动画,无济于事. CABasicAnimation *ani; ani = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; ani.fromValue = CGColorCreateGenericRGB(1.0,1.0,1.0); ani.toValue = CGColorCreateGenericRGB(1.0,0.0,1.0); ani.repeatCount = 2; ani.autoreverses = YES; ani.duration = 1.0; [[my_field layer] addAnimation:ani forKey:"backgroundColor"]; 完成这个建议? 解决方法
圣诞节快乐:
NSView *content = [[self window] contentView]; CALayer *layer = [content layer]; CABasicAnimation *anime = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; anime.fromValue = (id)[layer backgroundColor]; anime.toValue = (id)CGColorCreateGenericGray(0.0f,1.0f); anime.duration = 5.0f; anime.autoreverses = YES; [layer addAnimation:anime forKey:@"backgroundColor"]; 这将使用支持的图层动画化视图的背景颜色.记住要在init或awake中设置需求层: [[[self window] contentView] setWantsLayer:YES]; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – rails oauth和使用FB移动应用程序,如果我
- postgresql常用命令(持续更新中...)
- 可变的xml操作类似于lineinfile
- Sqlite ContentProvider Loader 上下文 对话框
- Aleo_Flash_Intro_Banner_Maker_V3.8 Win8报错
- 在PostgreSQL中重命名枚举项
- Nosql Mongodb之旅(13)—MongoDB 导入导出
- reactjs – React Navigation Header随屏幕变化
- 转:注意:请小心升级 flash 控件,有中文乱码的 bug
- c# – 将两个表直接添加到word文档中