ios 开发视图界面动态渲染
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios 开发视图界面动态渲染相关的知识,希望对你有一定的参考价值。
#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 开发视图界面动态渲染的主要内容,如果未能解决你的问题,请参考以下文章