欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

iOS生成圖片驗證碼繪制實例代碼-創(chuàng)新互聯(lián)

登錄注冊時用的驗證碼效果圖

成都創(chuàng)新互聯(lián)主營豐縣網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,成都app開發(fā),豐縣h5重慶小程序開發(fā)公司搭建,豐縣網(wǎng)站營銷推廣歡迎豐縣等地區(qū)企業(yè)咨詢

iOS 生成圖片驗證碼繪制實例代碼

ViewDidload調(diào)用即可

_pooCodeView = [[PooCodeView alloc] initWithFrame:CGRectMake(50, 100, 82, 32)];
 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
 [_pooCodeView addGestureRecognizer:tap];
[self.view addSubview:_pooCodeView];

#import <UIKit/UIKit.h>
@interface PooCodeView : UIView
@property (nonatomic, retain) NSArray *changeArray;
@property (nonatomic, retain) NSMutableString *changeString;
@property (nonatomic, retain) UILabel *codeLabel;
-(void)changeCode;
@end

#import "PooCodeView.h"
@implementation PooCodeView
@synthesize changeArray = _changeArray;
@synthesize changeString = _changeString;
@synthesize codeLabel = _codeLabel;

- (id)initWithFrame:(CGRect)frame
{
  self = [super initWithFrame:frame];
  if (self) {
    // Initialization code

//    self.layer.cornerRadius = 5.0;
//    self.layer.masksToBounds = YES;
    float red = arc4random() % 100 / 100.0;
    float green = arc4random() % 100 / 100.0;
    float blue = arc4random() % 100 / 100.0;
    UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:0.2];
    self.backgroundColor = color;
    [self change];
  }
  return self;
}
 //-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
//{
//  [self change];
//  [self setNeedsDisplay];
//}

-(void)changeCode{
[self change];
[self setNeedsDisplay];
}

 - (void)change
 {
   self.changeArray = [[NSArray alloc] initWithObjects:@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m",@"n",@"o",@"p",@"q",@"r",@"s",@"t",@"u",@"v",@"w",@"x",@"y",@"z",nil];

  NSMutableString *getStr = [[NSMutableString alloc] initWithCapacity:5];

  self.changeString = [[NSMutableString alloc] initWithCapacity:6];
  for(NSInteger i = 0; i < 4; i++)
  {
    NSInteger index = arc4random() % ([self.changeArray count] - 1);
    getStr = [self.changeArray objectAtIndex:index];

    self.changeString = (NSMutableString *)[self.changeString stringByAppendingString:getStr];
  }
  }

 - (void)drawRect:(CGRect)rect {
[super drawRect:rect];

  float red = arc4random() % 100 / 100.0;
  float green = arc4random() % 100 / 100.0;
  float blue = arc4random() % 100 / 100.0;

  UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:0.5];
  [self setBackgroundColor:color];

  NSString *text = [NSString stringWithFormat:@"%@",self.changeString];
  CGSize cSize = [@"S" sizeWithFont:[UIFont systemFontOfSize:20]];
  int width = rect.size.width / text.length - cSize.width;
  int height = rect.size.height - cSize.height;
  CGPoint point;

  float pX, pY;
  for (int i = 0; i < text.length; i++)
  {
    pX = arc4random() % width + rect.size.width / text.length * i;
    pY = arc4random() % height;
    point = CGPointMake(pX, pY);
    unichar c = [text characterAtIndex:i];
    NSString *textC = [NSString stringWithFormat:@"%C", c];
    [textC drawAtPoint:point withFont:[UIFont systemFontOfSize:20]];
  }

  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextSetLineWidth(context, 1.0);
  for(int cout = 0; cout < 10; cout++)
  {
    red = arc4random() % 100 / 100.0;
    green = arc4random() % 100 / 100.0;
    blue = arc4random() % 100 / 100.0;
    color = [UIColor colorWithRed:red green:green blue:blue alpha:0.2];
    CGContextSetStrokeColorWithColor(context, [color CGColor]);
    pX = arc4random() % (int)rect.size.width;
    pY = arc4random() % (int)rect.size.height;
    CGContextMoveToPoint(context, pX, pY);
    pX = arc4random() % (int)rect.size.width;
    pY = arc4random() % (int)rect.size.height;
    CGContextAddLineToPoint(context, pX, pY);
    CGContextStrokePath(context);
  }
}

@end

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)建站aaarwkj.com,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

網(wǎng)頁名稱:iOS生成圖片驗證碼繪制實例代碼-創(chuàng)新互聯(lián)
分享路徑:http://aaarwkj.com/article2/hoeoc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設網(wǎng)站建設、網(wǎng)站收錄、面包屑導航、網(wǎng)站設計公司手機網(wǎng)站建設

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設計公司
2021久久国产综合精品青草| 日本免费精品一区二区三区中| 国产精品黄色av一区二区| 一区二区中文字幕日本韩国| 天天日天天天干夜夜操| 久久精品一区二区东京热| 欧美一级特黄免费大片| 抱着操才爽的免费视频观看| 国产精品三级一区二区三区| heyzo高清中文字幕在线| 99热这里只有精品欧美| 日韩欧美一区精品在线观看| 国产精品主播自拍视频| 日韩黄片一区二区三区| 宅男视频在线观看视频| 日本高清免费黄色录像| 人妻免费精品久久一区| 午夜剧场福利在线观看| 黄色三级亚洲男人的天堂| 蜜桃视频在线观看91| 丁香色婷婷国产精品视频| 久久久精品国产亚洲av网黑人| 日本91大神在线观看| 妞妞婷婷基地五月天| 日本东京热在线免费观看 | 国产区青青操自拍视频| 午夜激情视频在线网站| 国产一区二区在线粉嫩| 女同亚洲一区二区三区| 日本韩国欧美在线一区| 国产在线精品91系列| 美女午夜福利一区二区| 欧美午夜一级特黄大片| 18禁超污网站免费观看| 久久久亚洲熟妇熟女一区二区| 一区二区不卡中文av| 国产免费av剧情演绎| 国产极品嫩模在线观看91| 久久久国产精品调教网站| 国产传媒免费在线播放| 久久99精品人妻一区二区三区|