我在Objective-c上还很陌生,我正在尝试使用for循环将标签数组设置为0.0 Alpha。有人可以帮我吗?

 NSArray *fadeLabels = @[@"_lonLabel", @"_firstLat",@"_firstLon",@"_firstReal",@"_firstMagnetic",@"_firstSpeed",@"_speedLabel",@"_realNorthLabel",@"_magneticNorthLabel"];

    for (int i=0; i<[fadeLabels count]; i++) {
        [fadeLabels objectAtIndex:i];
        //setAlpha:0.0f?
    }

最佳答案

使用视图数组而不是字符串数组。在数组中插入视图。

NSArray *fadeLabels = @[ _lonLabel, _firstLat, _firstLon, _firstReal, _firstMagnetic, _firstSpeed, _speedLabel, _realNorthLabel, _magneticNorthLabel];

for (int i=0; i<[fadeLabels count]; i++) {
    UIView *view = (UIView *)[fadeLabels objectAtIndex:i];
    [view setAlpha:0.0f];
}

10-04 18:16