iOS 设置View阴影效果
程序员文章站
2023-12-13 19:15:10
需要设置 颜色 阴影半径 等元素
uiview *shadowview = [[uiview alloc] init];
shadowview.frame =...
需要设置 颜色 阴影半径 等元素
uiview *shadowview = [[uiview alloc] init]; shadowview.frame = cgrectmake(100, 100, 100, 100); shadowview.center = self.view.center; shadowview.backgroundcolor = [uicolor whitecolor]; //设置阴影颜色 shadowview.layer.shadowcolor = [uicolor colorwithred:114.0/255.0 green:133.0/255.0 blue:152.0/255.0 alpha:1.0].cgcolor; //设置阴影的透明度 shadowview.layer.shadowopacity = 0.1f; //设置阴影的偏移 shadowview.layer.shadowoffset = cgsizemake(30.0f, 10.0f); //设置阴影半径 shadowview.layer.shadowradius = 15.0f; //设置渲染内容被缓存 shadowview.layer.shouldrasterize = yes; //超出父视图部分是否显示 shadowview.layer.maskstobounds = no; shadowview.layer.borderwidth = 0.0; shadowview.layer.opaque = 0.10; shadowview.layer.cornerradius = 3.0; //栅格化处理 shadowview.layer.rasterizationscale = [[uiscreen mainscreen]scale]; //正常矩形 uibezierpath *path = [uibezierpath bezierpathwithrect:shadowview.bounds]; shadowview.layer.shadowpath = path.cgpath; [self.view addsubview:shadowview];
总结
以上所述是小编给大家介绍的ios 设置view阴影效果,希望对大家有所帮助