zoukankan      html  css  js  c++  java
  • 为xib添加属性设置

    新建两个扩展类

    //
    //  UIView+XibConfiguration.h
    //  waimaibiz
    //
    //  Created by luningning02 on 16/11/25.
    //  Copyright © 2016年 meituan. All rights reserved.
    //

    #import <UIKit/UIKit.h>

    @interface UIView (XibConfiguration)

    @property (nonatomic, assign) IBInspectable UIColor *LayerColor;
    @property (nonatomic, assign) IBInspectable CGFloat  LayerWidth;
    @property (nonatomic, assign) IBInspectable CGFloat  LayerRadius;

    @property (nonatomic, assign) IBInspectable CGSize   ShadowOffset;
    @property (nonatomic, assign) IBInspectable CGFloat  ShadowRadius;
    @property (nonatomic, assign) IBInspectable CGFloat  ShadowOpacity;
    @property (nonatomic, assign) IBInspectable UIColor *ShadowColor;

    @end

    //
    //  UIView+XibConfiguration.m
    //  waimaibiz
    //
    //  Created by luningning02 on 16/11/25.
    //  Copyright © 2016年 meituan. All rights reserved.
    //

    #import "UIView+XibConfiguration.h"

    @implementation UIView (XibConfiguration)

    -(UIColor*)borderUIColor {
        return [UIColor colorWithCGColor:self.layer.borderColor];
    }
    -(void)setLayerColor:(UIColor *)LayerColor_ {
        self.layer.borderColor = LayerColor_.CGColor;
    }
    - (UIColor *)LayerColor {
        return [UIColor colorWithCGColor:self.layer.borderColor];
    }

    - (void)setLayerWidth:(CGFloat)LayerWidth_ {
        self.layer.borderWidth = LayerWidth_;
        self.layer.allowsEdgeAntialiasing = YES;// 解决layer.border.width随着view的放大,会出现锯齿化的问题(iOS7.0)
    }
    - (CGFloat)LayerWidth {
        return self.layer.borderWidth;
    }

    - (void)setLayerRadius:(CGFloat)LayerRadius_ {
        self.layer.cornerRadius = LayerRadius_;
    }
    - (CGFloat)LayerRadius {
        return self.layer.cornerRadius;
    }

    - (void)setShadowOffset:(CGSize)ShadowOffset_ {
        self.layer.shadowOffset = ShadowOffset_;
    }
    - (CGSize)ShadowOffset {
        return self.layer.shadowOffset;
    }

    - (void)setShadowRadius:(CGFloat)ShadowRadius_ {
        self.layer.shadowRadius = ShadowRadius_;
    }
    - (CGFloat)ShadowRadius {
        return self.layer.shadowRadius;
    }

    - (void)setShadowOpacity:(CGFloat)ShadowOpacity_ {
        self.layer.shadowOpacity = ShadowOpacity_;
    }
    - (CGFloat)ShadowOpacity {
        return self.layer.shadowOpacity;
    }

    - (void)setShadowColor:(UIColor *)ShadowColor_ {
        self.layer.shadowColor = ShadowColor_.CGColor;
    }
    - (UIColor *)ShadowColor {
        return [UIColor colorWithCGColor:self.layer.shadowColor];
    }

    @end

    运行成功之后就可以在xib上看见属性设置的框框了

  • 相关阅读:
    PHP实反向代理-收藏
    微信小程序实例-获取当前的地理位置、速度
    Entity Framework Core 实现读写分离
    将ASP.NET Core应用程序部署至生产环境中(CentOS7)(转)
    Centos 7防火墙firewalld开放80端口
    Asp.net Core 使用Redis存储Session
    .net core 使用Autofac依赖注入
    .net core 1.0 实现负载多服务器单点登录
    用ASP.NET Core 1.0中实现邮件发送功能-阿里云邮件推送篇
    阿里大鱼.net core 发送短信
  • 原文地址:https://www.cnblogs.com/luningning0901/p/6101837.html
Copyright © 2011-2022 走看看