请解释这个目标C code [英] Please explain this Objective-C code

查看:86
本文介绍了请解释这个目标C code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ref1view.hidden = NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.25f];
[ref1view setAlpha:([ref1view alpha] == 1.0f) ? 0.0f : 1.0f];
[UIView commitAnimations];

任何人都可以请给我如何工作的细分?特别是这一行:

Can anyone please give me a breakdown of how this works? Specifically this line:

[ref1view setAlpha:([ref1view alpha] == 1.0f) ? 0.0f : 1.0f];

看来,这个功能会从0-1 1-0从动画的alpha和回来,我只是不明白的语法。
谢谢!

It seems that this function will animate the alpha from 0-1 and back from 1-0 and I just don't understand the syntax. Thanks!

推荐答案

[ref1view setAlpha:([ref1view阿尔法] == 1)? 0.0:1.0F];

设定 ref1view 为1,如果是0,或者0,如果是1,这就是所谓的三元运算符的简写的字母的if-else

Sets the alpha of ref1view to be 1 if it's 0, or 0 if it's 1. This is called the ternary operator, a shorthand if-else.

(condition) ? conditionistrue : conditionisfalse;

这篇关于请解释这个目标C code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆