仿支付寶密碼輸入

自定義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];
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 思路:設(shè)置一個textField隱藏,然后遍歷輸入的內(nèi)容,展示在四個textField中,代碼如下: 效果圖如下:...
    Lonely__M閱讀 7,153評論 6 21
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,777評論 25 709
  • 1.概述 最近有人在問我要所有項目的代碼,我在這里聲明一下我不是這幾個項目公司內(nèi)部人員,之所以錄視頻和寫博客也是喜...
    紅橙Darren閱讀 10,117評論 7 46
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,060評論 4 61
  • 運(yùn)交華蓋欲何求?未敢翻身已碰頭。破帽遮顏過鬧市,漏船載酒泛中流。橫眉冷對千夫指,俯首甘為孺子牛。躲進(jìn)小樓成一統(tǒng),管...
    康恩飯閱讀 270評論 0 0

友情鏈接更多精彩內(nèi)容