国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

ios 代碼控制 出現控件的陰影

2019-11-02 14:49:31
字體:
來源:轉載
供稿:網友

  只需要把對應的空間,進行重寫。我開發的主要針對UIButton這個控件

  .h文件,如下:

  #import

  #import

  @interface ShadowButton : UIButton

  {

  UIColor *shadowColor;

  }

  @property(nonatomic , strong)UIColor *shadowColor;

  @end

  .m文件,如下

  #import "ShadowButton.h"

  @implementation ShadowButton

  @synthesize shadowColor;

  -(void)setProperty

  {

  self.imageEdgeInsets = UIEdgeInsetsMake(0, -1, 3, 2);

  self.shadowColor = [UIColor grayColor];

  }

  - (id)initWithFrame:(CGRect)frame

  {

  self = [super initWithFrame:frame];

  if (self) {

  // Initialization code

  }

  return self;

  }

  -(id)initWithCoder:(NSCoder *)aDecoder

  {

  self = [super initWithCoder:aDecoder];

  if (self) {

  [self setProperty];

  }

  return self;

  }

  // Only override drawRect: if you perform custom drawing.

  // An empty implementation adversely affects performance during animation.

  - (void)drawRect:(CGRect)rect

  {

  // Drawing code

  CGContextRef context = UIG

搞笑段子[www.62-6.com/1/gaoxiaoduanzi/]
raphicsGetCurrentContext();

  CGRect frame = rect;

  UIEdgeInsets insets = self.imageEdgeInsets;

  frame.origin.x +=insets.left;

  frame.origin.y +=insets.top;

  frame.size.width -= (insets.left + insets.right);

  frame.size.height -= (insets.top + insets.bottom);

  if (shadowColor) {

  CGContextSetShadowWithColor(context, CGSizeMake(insets.right, insets.bottom), 10, [shadowColor CGColor]);

  }

  UIImage *image = self.imageView.image;

  [image drawInRect:frame];

  }

  @end

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汉中市| 射阳县| 林西县| 宜昌市| 拜城县| 东辽县| 北京市| 尼玛县| 山阴县| 浙江省| 芜湖县| 华安县| 曲周县| 保靖县| 建始县| 德昌县| 咸丰县| 友谊县| 崇信县| 荔浦县| 张家口市| 皋兰县| 万盛区| 临漳县| 孝义市| 白河县| 汉中市| 凤冈县| 威信县| 三原县| 海盐县| 庐江县| 琼中| 锦屏县| 静安区| 洛川县| 商洛市| 永平县| 台南市| 五原县| 治多县|