簡單地記錄一下:
#import <QuartzCore/QuartzCore.h> //import必要的class,用於設定效果
UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; //建立view
baseView
.backgroundColor = [UIColor whiteColor]; //將背景設成白色
baseView.layer.cornerRadius=5; //加入圓角
baseView.layer.borderWidth=1; //設定邊闊
baseView.layer.borderColor=
[UIColor colorWithRed:161/255.0 green:47/255.0 blue:47/255.0 alpha:1]; //以rgb來設定邊的顏色
//陰影
baseView
.layer.shadowColor = [[UIColor blackColor] CGColor];
baseView
.layer.shadowOffset = CGSizeMake(3.0f, 3.0f);
baseView
.layer.shadowOpacity = 0.5f;
baseView
.layer.shadowRadius = 10.0f;
//漸層
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame =
baseView
.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor grayColor] CGColor], nil];
[
baseView
.layer insertSublayer:gradient atIndex:0];
[self.view addSubview:baseView]; //將baseView加入到場景
[self.view sendSubviewToBack:baseView]; //將baseView的層次推後一層
[self.view bringSubviewToFront:baseView]; //將baseView的層次拉上一層
沒有留言:
張貼留言