本篇文章主要介绍了iOS 图片验证码绘制实例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
登录注册时用的验证码效果图

ViewDidload调用即可
 _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];
/
				 沃梦达教程
				
			本文标题为:iOS 生成图片验证码绘制实例代码
				
        
 
            
        基础教程推荐
             猜你喜欢
        
	     - iOS如何去掉导航栏(UINavigationBar)下方的横线 2023-03-07
 - Android socket如何实现文件列表动态访问 2023-04-05
 - Android自定义View验证码输入框 2023-02-04
 - Android Kotlin使用SQLite案例详解 2023-04-16
 - 如何在iOS中高效的加载图片详解 2023-07-02
 - Android自定义View实现地铁显示牌效果 2023-01-01
 - Android Studio实现下拉列表效果 2023-05-23
 - android: targetSdkVersion升级中Only fullscreen activities can request orientation问题的解决方法 2022-11-05
 - iOS输入框的字数统计/最大长度限制详解 2023-06-03
 - 详解ios11中estimatedRowHeight属性 2023-04-24
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				