gpt4 book ai didi

ios - 以编程方式更改 UIImage 的 Alpha

转载 作者:行者123 更新时间:2023-11-28 18:01:14 26 4
gpt4 key购买 nike

我仍在探索 xCode/Objective-C,我想知道如何才能更改 UIImage 的 alpha。我尝试编写自己的代码,但出现错误“在 UIImage 类型的对象上找不到属性‘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

//谢谢!

最佳答案

您需要更改包含它的 UIImageView 的 alpha,UIImage 没有 alpha 属性。

关于ios - 以编程方式更改 UIImage 的 Alpha,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24435477/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com