我正在尝试创建一个计时器栏,但是在timerBar.bounds.size.width = 0上出现错误“无法分配表达式”

(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.view.backgroundColor = [UIColor blueColor];

timerBar = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH , 5)];
timerBar.backgroundColor = [UIColor whiteColor];
[self.view addSubview:timerBar];

[UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
    timerBar.bounds.size.width = 0;
} completion:^(BOOL finished) {

}];

}


我究竟做错了什么?为什么不能分配值?

最佳答案

您无法将“边界宽度”直接设置为零!

CGFloat width = 0;
timerBar.bounds = CGRectMake(0, 0, width , 5)

关于ios - 在timerBar.bounds.size.width分配上出现错误“表达式无法分配”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26422803/

10-13 05:02