本篇文章主要介绍了iOS 图片验证码绘制实例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
登录注册时用的验证码效果图
_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实现动态背景页面 2023-05-23
- SurfaceView播放视频发送弹幕并实现滚动歌词 2023-01-02
- iOS 对当前webView进行截屏的方法 2023-03-01
- 详解flutter engine 那些没被释放的东西 2022-12-04
- Android MaterialButton使用实例详解(告别shape、selector) 2023-06-16
- 作为iOS开发,这道面试题你能答出来,说明你基础很OK! 2023-09-14
- Android实现轮询的三种方式 2023-02-17
- Flutter实现底部和顶部导航栏 2022-08-31
- Android实现监听音量的变化 2023-03-30
- 最好用的ios数据恢复软件:PhoneRescue for Mac 2023-09-14