不要在预览中显示IB_DESIGNABLE视图吗?
编辑按要求的代码屏幕截图:
H=#import <UIKit/UIKit.h>IB_DESIGNABLE@interface TitleBannerVIEw : UILabel@property (nonatomic) IBInspectable CGfloat borderWIDth;@property (nonatomic) IBInspectable CGfloat cornerRadius;@property (nonatomic) IBInspectable CGfloat shadowHeight;@endM=@implementation TitleBannerVIEw@synthesize borderWIDth;@synthesize cornerRadius;@synthesize shadowHeight;- (voID)drawRect:(CGRect)rect { if (self.borderWIDth == 0) self.borderWIDth = 8.5; if (self.cornerRadius == 0) self.cornerRadius = 33; if (self.shadowHeight == 0) self.shadowHeight = 15.1; CGContextRef context = UIGraphicsGetCurrentContext(); //// color Declarations UIcolor* bG = [UIcolor colorWithRed: 0.18 green: 0.8 blue: 0.443 Alpha: 1]; UIcolor* bordercolor = [UIcolor colorWithRed: 0.557 green: 0.267 blue: 0.678 Alpha: 1]; UIcolor* shadowcolor2 = [UIcolor colorWithRed: 0.976 green: 0.859 blue: 0.718 Alpha: 1]; //// Shadow Declarations UIcolor* shadow = shadowcolor2; CGSize shadowOffset = CGSizeMake(-4.1,self.shadowHeight); CGfloat shadowBlurRadius = 1.5;
//
//// Frames CGRect frame = self.bounds; //// Subframes CGRect group = CGRectMake(CGRectGetMinX(frame) + 15,CGRectGetMinY(frame) + 15,CGRectGetWIDth(frame) - 28,CGRectGetHeight(frame) - 40); //// Abstracted Attributes CGfloat roundedRectanglestrokeWIDth = self.borderWIDth ; CGfloat roundedRectangleCornerRadius = self.cornerRadius; //// Group { //// Rounded Rectangle Drawing UIBezIErPath* roundedRectanglePath = [UIBezIErPath bezIErPathWithRoundedRect: CGRectMake(CGRectGetMinX(group) + floor(CGRectGetWIDth(group) * 0.00060) + 0.5,CGRectGetMinY(group) + floor(CGRectGetHeight(group) * 0.00568) + 0.5,floor(CGRectGetWIDth(group) * 0.99940) - floor(CGRectGetWIDth(group) * 0.00060),floor(CGRectGetHeight(group) * 0.99432) - floor(CGRectGetHeight(group) * 0.00568)) cornerRadius: roundedRectangleCornerRadius]; CGContextSaveGState(context); CGContextSetShadowWithcolor(context,shadowOffset,shadowBlurRadius,shadow.CGcolor); [bG setFill]; [roundedRectanglePath fill]; CGContextRestoreGState(context); [bordercolor setstroke]; roundedRectanglePath.linewidth = roundedRectanglestrokeWIDth; [roundedRectanglePath stroke]; }}@end
TitleBannerVIEw是绿色的视图,带有紫色边框.
您是否在框架中声明了IBDesignable类? IBInspectable ONLY仅支持在框架中声明时的预览.
另外,请记住(不是你的情况):
>你的抽奖代码应该足够快,你只有100毫秒的抽奖时间.>经常需要prepareForInterfaceBuilder()方法.
总结以上是内存溢出为你收集整理的ios – IB_DESIGNABLE,在预览中显示视图?全部内容,希望文章能够帮你解决ios – IB_DESIGNABLE,在预览中显示视图?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)