zoukankan      html  css  js  c++  java
  • 自己无聊封装一个 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

  • 相关阅读:
    npm,umi,yarn
    PHPStorm 快捷键, 到页面顶部和底部
    百度统计
    公共管理之重置密码
    ALT+J 多行编辑
    PHP,Excel导出换行
    art-template 弹出上传多图
    java mock
    mysql查找字符串出现位置
    Spring 依赖注入,在Main方法中取得Spring控制的实例
  • 原文地址:https://www.cnblogs.com/lhp-1992/p/4617331.html
Copyright © 2011-2022 走看看