仿支付宝密码输入

自定义view

PassWordView.h

@interface PassWordView : UIView
@property (weak ,nonatomic)UILabel * alertLabel;
@property (weak ,nonatomic)UITextField * passWordFiled;
@property (weak ,nonatomic)UIImageView * inserImageView;
@end

PassWordView.m

@interface PassWordView ()

@end

@implementation PassWordView

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI
{
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, [UIScreen mainScreen].bounds.size.width, 20)];
    label.text = @"请输入云理想支付密码";
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:[UIFont smallSystemFontSize]];
    self.alertLabel = label;
    [self addSubview:self.alertLabel];
    
//    UIImageView * inserImageView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 35, kScreen_Width-60, 60)];
    UIImageView * inserImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 35, kScreen_Width-20, (kScreen_Width-20)/6)];
    [inserImageView setImage:[UIImage imageNamed:@"bg_textF"]];
    self.inserImageView = inserImageView;
    [self addSubview:self.inserImageView];
    
    for (int i = 0; i < 6; i ++) {
        UIView * point = [[UIView alloc] init];
        CGFloat x = ((kScreen_Width-20)/6/2-7.5) + (kScreen_Width-20)/6*i;
        point.frame = CGRectMake(x, (kScreen_Width-20)/6/2 - 7.5, 15, 15);
        point.layer.cornerRadius = 7.5;
        point.layer.masksToBounds = YES;
        point.tag = i + 1;
        point.hidden = YES;
        point.userInteractionEnabled = YES;
        point.backgroundColor = [UIColor blackColor];
        [inserImageView addSubview:point];
    }
    
//    UIButton * sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    sureButton.frame = CGRectMake(30, 120, kScreen_Width - 60, 40);
//    sureButton.enabled = NO;
//     [ButtonUtil setButtonSelectorWithNormalcolor:APP_BG AndHeighColor:SELECTOR_COLOR AndButton:sureButton];
//    [sureButton setTitle:@"下一步" forState:UIControlStateNormal];
//    [sureButton addTarget:self action:@selector(sureButtonClick) forControlEvents:UIControlEventTouchUpInside];
//    self.sureButton = sureButton;
//    [self addSubview:self.sureButton];
    
    
//    输入框
    UITextField * textFiled = [[UITextField alloc] initWithFrame:CGRectMake(kScreen_Width +10, 30, 80, 30)];
    textFiled.keyboardType = UIKeyboardTypeNumberPad;
    [textFiled becomeFirstResponder];
    
    self.passWordFiled = textFiled;
    [self addSubview:textFiled];
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 思路:设置一个textField隐藏,然后遍历输入的内容,展示在四个textField中,代码如下: 效果图如下:...
    Lonely__M阅读 11,912评论 6 21
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,526评论 25 709
  • 1.概述 最近有人在问我要所有项目的代码,我在这里声明一下我不是这几个项目公司内部人员,之所以录视频和写博客也是喜...
    红橙Darren阅读 13,320评论 7 46
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,216评论 4 61
  • 运交华盖欲何求?未敢翻身已碰头。破帽遮颜过闹市,漏船载酒泛中流。横眉冷对千夫指,俯首甘为孺子牛。躲进小楼成一统,管...
    康恩饭阅读 1,560评论 0 0