本篇文章主要介绍了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 生成图片验证码绘制实例代码


基础教程推荐
猜你喜欢
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
- Android多返回栈技术 2023-04-15
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- Android中的webview监听每次URL变化实例 2023-01-23
- android studio按钮监听的5种方法实例详解 2023-01-12
- Flutter手势密码的实现示例(附demo) 2023-04-11
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- IOS应用内跳转系统设置相关界面的方法 2022-11-20