UIImage加阴影
生活随笔
收集整理的這篇文章主要介紹了
UIImage加阴影
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
#import <QuartzCore/QuartzCore.h>
一、給圖片加上陰影?
UIImageView*pageContenterImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"onePageApple.png"]];//添加邊框CALayer*layer = [pageContenterImageView layer];layer.borderColor= [[UIColor whiteColor]CGColor];layer.borderWidth=0.0f;//添加四個邊陰影pageContenterImageView.layer.shadowColor= [UIColor blackColor].CGColor;pageContenterImageView.layer.shadowOffset=CGSizeMake(0,0);pageContenterImageView.layer.shadowOpacity=0.5; pageContenterImageView.layer.shadowRadius=5.0;//添加兩個邊陰影//pageContenterImageView.layer.shadowColor = [UIColor blackColor].CGColor;// pageContenterImageView.layer.shadowOffset = CGSizeMake(2, 2);// pageContenterImageView.layer.shadowOpacity = 0.5; // pageContenterImageView.layer.shadowRadius = 2.0;//-------------陰影渲染會嚴(yán)重消耗內(nèi)存 ,導(dǎo)致程序咔嘰./*陰影效果*///添加邊框CALayer*layer = [self.pageContenter layer];layer.borderColor= [[UIColorwhiteColor]CGColor];layer.borderWidth=0.0f;//添加四個邊陰影self.pageContenter.layer.shadowColor= [UIColorblackColor].CGColor;//陰影顏色self.pageContenter.layer.shadowOffset=CGSizeMake(0,0);//陰影偏移self.pageContenter.layer.shadowOpacity=0.5;//陰影不透明度self.pageContenter.layer.shadowRadius=5.0;//陰影半徑//添加兩個邊陰影//self.pageContenter.layer.shadowColor = [UIColor blackColor].CGColor;//self.pageContenter.layer.shadowOffset = CGSizeMake(2, 2);//self.pageContenter.layer.shadowOpacity = 0.5; //self.pageContenter.layer.shadowRadius = 2.0;
二、給視圖加上陰影
UIView * content=[[UIView alloc] initWithFrame:CGRectMake(100, 250, 503, 500)]; content.backgroundColor=[UIColor orangeColor];//content.layer.shadowOffset=10;content.layer.shadowOffset = CGSizeMake(5, 3);content.layer.shadowOpacity = 0.6;content.layer.shadowColor = [UIColor blackColor].CGColor;[self.window addSubview:content];
一、給圖片加上陰影?
UIImageView*pageContenterImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"onePageApple.png"]];//添加邊框CALayer*layer = [pageContenterImageView layer];layer.borderColor= [[UIColor whiteColor]CGColor];layer.borderWidth=0.0f;//添加四個邊陰影pageContenterImageView.layer.shadowColor= [UIColor blackColor].CGColor;pageContenterImageView.layer.shadowOffset=CGSizeMake(0,0);pageContenterImageView.layer.shadowOpacity=0.5; pageContenterImageView.layer.shadowRadius=5.0;//添加兩個邊陰影//pageContenterImageView.layer.shadowColor = [UIColor blackColor].CGColor;// pageContenterImageView.layer.shadowOffset = CGSizeMake(2, 2);// pageContenterImageView.layer.shadowOpacity = 0.5; // pageContenterImageView.layer.shadowRadius = 2.0;//-------------陰影渲染會嚴(yán)重消耗內(nèi)存 ,導(dǎo)致程序咔嘰./*陰影效果*///添加邊框CALayer*layer = [self.pageContenter layer];layer.borderColor= [[UIColorwhiteColor]CGColor];layer.borderWidth=0.0f;//添加四個邊陰影self.pageContenter.layer.shadowColor= [UIColorblackColor].CGColor;//陰影顏色self.pageContenter.layer.shadowOffset=CGSizeMake(0,0);//陰影偏移self.pageContenter.layer.shadowOpacity=0.5;//陰影不透明度self.pageContenter.layer.shadowRadius=5.0;//陰影半徑//添加兩個邊陰影//self.pageContenter.layer.shadowColor = [UIColor blackColor].CGColor;//self.pageContenter.layer.shadowOffset = CGSizeMake(2, 2);//self.pageContenter.layer.shadowOpacity = 0.5; //self.pageContenter.layer.shadowRadius = 2.0;
二、給視圖加上陰影
UIView * content=[[UIView alloc] initWithFrame:CGRectMake(100, 250, 503, 500)]; content.backgroundColor=[UIColor orangeColor];//content.layer.shadowOffset=10;content.layer.shadowOffset = CGSizeMake(5, 3);content.layer.shadowOpacity = 0.6;content.layer.shadowColor = [UIColor blackColor].CGColor;[self.window addSubview:content];
轉(zhuǎn)載于:https://www.cnblogs.com/zzzili/archive/2012/12/20/6662662.html
《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的UIImage加阴影的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: div+css如何让一行内的文字两端对齐
- 下一篇: hibernate 高级映射 --张国亮