网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

利用drawinrect在control中画入图片和文字-创新互联

//

成都创新互联是一家专业提供茌平企业网站建设,专注与网站设计、做网站H5建站、小程序制作等业务。10年已为茌平众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。

//  BtnControl.m

//  ZCar

//

//  Created by imac on 15/10/4.

//  Copyright (c) 2015年 imac. All rights reserved.

//

#import "BtnControl.h"

@implementation BtnControl

-(instancetype)initWithFrame:(CGRect)frame

{

  self = [super initWithFrame:frame];

  if (self) {

     

      self.layer.borderColor = [UIColor lightGrayColor].CGColor;

      self.layer.borderWidth = 1;

      self.backgroundColor = [UIColor whiteColor];

     

  }

  return self;

}

-(void)setNameWithTitle:(NSString *)nameWithTitle

{

  if (_nameWithTitle != nameWithTitle) {

      _nameWithTitle = nameWithTitle;

      [self setNeedsDisplay];

  }

}

- (void)setImgName:(NSString *)imgName

{

  if (_imgName != imgName) {

      _imgName = imgName;

      [self setNeedsDisplay];

  }

}

- (void)setDic:(NSDictionary *)dic

{

  if (_dic != dic) {

      _dic = dic;

      [self setNeedsDisplay];

  }

}

- (void)drawRect:(CGRect)rect

{

  [super drawRect:rect];

  [self drawWithText:_nameWithTitle ImgName:_imgName titleColor:_dic];

}

- (void)drawWithText:(NSString *)title ImgName:(NSString *)imgName titleColor:(NSDictionary *)dic{

 

  UIImage *img = [UIImage p_w_picpathNamed:imgName];

  [img drawInRect:CGRectMake(self.width - 27, self.height - 12, 25, 10)];

  int i = [self convertToInt:title];

  float width = (self.width - i * 12) / 2;

  [title drawInRect:CGRectMake(width, 10, self.width, self.height) withAttributes:dic];

}

-  (int)convertToInt:(NSString*)strtemp {

 

  int strlength = 0;

 

  char* p = (char*)[strtemp cStringUsingEncoding:NSUnicodeStringEncoding];

  for (int i=0 ; i<[strtemp lengthOfBytesUsingEncoding:NSUnicodeStringEncoding] ;i++) {

      if (*p) {

          p++;

          strlength ++;

      }

      else {

          p ++;

      }

  }

  return (strlength + 1) / 2;

 

}

@end


创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


网页标题:利用drawinrect在control中画入图片和文字-创新互联
本文链接:http://bjjierui.cn/article/ccgohj.html

其他资讯