以编程方式更改UIImage的Alpha

Bru*_*ose 0 xcode splash-screen objective-c uiimage ios

我还在探索xCode/Objective-C,我想知道如何能够改变UIImage的alpha.我尝试编写自己的代码,但是在UIImage类型的对象上找不到错误'Property'alpha'.如果我注释掉alpha变化线,则启动画面会起作用.我的代码如下.

//
//  ViewController.m

#import "ViewController.h"

@interface ViewController ()

@property (nonatomic,weak) IBOutlet UIImage *logo;

@end

@implementation ViewController

ADBannerView *_bannerView;
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view addSubview:_bannerView];

    [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(showLogo:) userInfo:nil repeats:NO];

}

- (void)showLogo:(NSTimer *) timer{
    [UIView animateWithDuration:2.0 animations:^{
    self.logo.alpha = 1.0;
} completion:^(BOOL finished){

    [UIView animateWithDuration:2.0 animations:^{
        self.logo.alpha = 0.0;
    } completion:^(BOOL finished){
        ViewController *controller  = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
        [self.navigationController pushViewController:controller animated:YES];
    }];

}];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
Run Code Online (Sandbox Code Playgroud)

//谢谢!

JMa*_*rsh 6

你需要改变UIImageView它所包含的alpha,没有alpha属性UIImage.