zoukankan      html  css  js  c++  java
  • 导航栏底部添加阴影

    //
    // UINavigationBar+JTDropShadow.h
    //
    // Created by james on 9/20/11.
    // http://ioscodesnippet.tumblr.com
    //


    #import

    @interface UINavigationBar (JTDropShadow)

    - (void)dropShadowWithOffset:(CGSize)offset
    radius:(CGFloat)radius
    color:(UIColor *)color
    opacity:(CGFloat)opacity;


    @end




    //
    // UINavigationBar+JTDropShadow.m
    //
    // Created by james on 9/20/11.
    // http://ioscodesnippet.tumblr.com
    //


    #import "UINavigationBar+JTDropShadow.h"

    #import



    @implementation UINavigationBar (JTDropShadow)

    - (void)dropShadowWithOffset:(CGSize)offset
    radius:(CGFloat)radius
    color:(UIColor *)color
    opacity:(CGFloat)opacity {

    // Creating shadow path for better performance
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathAddRect(path, NULL, self.bounds);
    self.layer.shadowPath = path;
    CGPathCloseSubpath(path);
    CGPathRelease(path);

    self.layer.shadowColor = color.CGColor;
    self.layer.shadowOffset = offset;
    self.layer.shadowRadius = radius;
    self.layer.shadowOpacity = opacity;

    // Default clipsToBounds is YES, will clip off the shadow, so we disable it.
    self.clipsToBounds = NO;

    }

    @end


    //用法如下

    - (void)viewDidLoad {
    [super viewDidLoad];
    ...
    [self.navigationController.navigationBar dropShadowWithOffset:CGSizeMake(0, 3)
    radius:1
    color:[UIColor darkGrayColor]
    opacity:1];
    ...
    }

  • 相关阅读:
    jmeter笔记5
    jmeter笔记4
    jmeter笔记3
    jmeter笔记2
    jmeter笔记1
    robot API笔记4
    robotframework笔记27
    robotframework笔记25
    robotframework笔记26
    robotframework笔记24
  • 原文地址:https://www.cnblogs.com/mgbert/p/4092469.html
Copyright © 2011-2022 走看看