-1
我需要知道我做错了什么。我字面上复制并粘贴到我的代码和梯度不显示。我的CAGradientLayer未显示?
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIView *gradient_view = [[UIView alloc]initWithFrame:self.view.bounds];
CAGradientLayer *gradient_layer = [CAGradientLayer layer];
[gradient_layer setFrame:gradient_view.bounds];
gradient_layer.startPoint = CGPointMake(0, 0);
gradient_layer.endPoint = CGPointMake(0, 1);
UIColor *top_color = [UIColor redColor];
UIColor *bottom_color = [UIColor blueColor];
[gradient_layer setColors:@[top_color,bottom_color]];
[gradient_view.layer addSublayer:gradient_layer];
[self.view addSubview:gradient_view];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
它只是显示一个白色屏幕。任何人都可以帮助我找出问题所在。导致它现在真的让我感到困扰。
Im相当肯定我这样做了,不过生病尝试再次UT斯达康出来 – Esko918