码迷,mamicode.com
首页 > 移动开发 > 详细

ios 开发视图界面动态渲染

时间:2016-02-25 10:16:54      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

#import "MyView.h"
IB_DESIGNABLE

@interface MyView ()
@property (nonatomic, strong) IBInspectable UIColor * borderColor;
@property (nonatomic, assign) IBInspectable CGFloat borderWidth;
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;
@end

@implementation MyView

- (void)setBorderColor:(UIColor *)borderColor {
    self.layer.borderColor = borderColor.CGColor;
}

- (void)setBorderWidth:(CGFloat)borderWidth {
    self.layer.borderWidth = borderWidth;
}

-(void)setCornerRadius:(CGFloat)cornerRadius {
    self.layer.cornerRadius = cornerRadius;
}

@end

 

----------------------

在swift中使用

import UIKit
@IBDesignable
class TestVIew: UIView {
    
    @IBInspectable var borderColor: UIColor! = UIColor.clearColor() {
        didSet {
            self.layer.borderColor = borderColor.CGColor
        }
    }
    
    @IBInspectable var borderWidth: CGFloat = 0 {
        didSet {
            self.layer.borderWidth = borderWidth
        }
    }
    @IBInspectable var cornerRadius: CGFloat = 0 {
        didSet {
            self.layer.cornerRadius = cornerRadius
        }
    }
}

 

技术分享

 

ios 开发视图界面动态渲染

标签:

原文地址:http://www.cnblogs.com/qzp2014/p/5215964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!