zoukankan      html  css  js  c++  java
  • Adding A Shadow To UIView

    参考: http://nscookbook.com/2013/01/ios-programming-recipe-10-adding-a-shadow-to-uiview/

    shadowOffset
    is a CGSize representing how far to offset the shadow from the path.

    shadowColor
    is the color of the shadow. Shadow colors should always be opaque, because the opacity will be set by the shadowOpacity property. The shadowColor property is a CGColor not a UIColor.

    shadowRadius
    is the width of the shadow along the shadow path
    he blur radius (in points) used to render the layer’s shadow

    shadowOpacity
    determines the opacity of the shadow.

    shadowPath
    is probably the most important of the properties. While a shadow can be drawn without specifying a path, for performance reasons you should always specify one. This path tells Core Animation what the opaque regions of the view are, and without it, things slow down severely! It is a CGPath, which is most easily created using UIBezierPath (iOS only)

    按钮左边添加阴影
    - (CGPathRef)fancyShadowForRect:(CGRect)rect
    {
    CGSize size = rect.size;
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointZero];
    [path addLineToPoint:CGPointMake(-12, 7)];
    [path addLineToPoint:CGPointMake(-12, size.height - 7)];
    [path addLineToPoint:CGPointMake(0, size.height - 7)];
    [path closePath];
    return path.CGPath;
    }


    plusBtn.layer.shadowOffset = CGSizeZero;
    plusBtn.layer.shadowOpacity = 0.9;
    plusBtn.layer.shadowColor = [[UIColor whiteColor] CGColor];
    plusBtn.layer.shadowRadius = 5;
    plusBtn.layer.shadowPath = [self fancyShadowForRect:plusBtn.bounds];

  • 相关阅读:
    【转】苹果App Store审核指南中文翻译(更新)
    ios中的coredata的使用
    iOS开发——网络编程OC篇&Socket编程
    [深入浅出Cocoa]iOS网络编程之Socket
    RESTful架构详解
    IOS开发 REST请求 ASIHTTPRequest用法
    iOS 8 AutoLayout与Size Class自悟
    nodejs入门demo
    微信公众号查询账户余额等
    微信公众号token验证失败的一些总结
  • 原文地址:https://www.cnblogs.com/qike/p/5561345.html
Copyright © 2011-2022 走看看