• 自己无聊封装一个 LTView


    //

    //  LTView.m

    //  UI_Lesson_LTView

    //

    //  Created by 李洪鹏 on 15/7/2.

    //  Copyright (c) 2015年 李洪鹏. All rights reserved.

    //

    #import "LTView.h"

    @interface LTView() <UITextFieldDelegate>

    @property (nonatomic, retain) UILabel *label;

    @property (nonatomic, retain) UITextField *textField;

    @end

    @implementation LTView

    //通过属性设置子控件的delegate

    - (void)setDelegate:(id<UITextFieldDelegate>)delegate

    {

        self.textField.delegate = delegate;

    }

    - (instancetype)initWithFrame:(CGRect)frame label:(NSString *)label textFieldPlaceHolder:(NSString *)text

    {

        self = [super initWithFrame:frame];

        if (self) {

            

            //创建 label

            self.label = [[[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width / 4, self.frame.size.height)] autorelease];

            self.label.text = label;

            [self addSubview:_label];

            

            //创建 textField

            self.textField = [[[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.label.frame), 0, self.frame.size.width / 4 * 3, self.frame.size.height)] autorelease];

            self.textField.placeholder = text;

            self.textField.borderStyle = UITextBorderStyleRoundedRect;

            [self addSubview:_textField];  

        }

        return self;

        

    }

    -(void)dealloc

    {

        [_label release];

        [_textField release];

        [super dealloc];

    }

    @end

  • 相关阅读:
    错误:找不到或无法加载主类
    CentOS 7 命令
    CentOS 7 分区
    Pow(x, n)
    Sum Root to Leaf Numbers
    linux下intel 82579LM 网卡驱动安装
    printf打印字符耗时多少
    数组中移动0至后面
    SDL多线程问题之--Unknown request in queue while dequeuing
    java学习123>>IO
  • 原文地址:https://www.cnblogs.com/lhp-1992/p/4617331.html
Copyright © 2020-2023  润新知