小编Bru*_*ose的帖子

以编程方式更改UIImage的Alpha

我还在探索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. …
Run Code Online (Sandbox Code Playgroud)

xcode splash-screen objective-c uiimage ios

0
推荐指数
1
解决办法
7605
查看次数

标签 统计

ios ×1

objective-c ×1

splash-screen ×1

uiimage ×1

xcode ×1