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

  • 相关阅读:
    cs
    PC管理端与评委云打分配合步骤及疑难问题汇编,即如何使用PC管理端的云服务管理功能
    B.数据结构(栈和队列)
    13.Python(模块)
    A.数据结构(线性表)
    c.Matlab(数据和函数的可视化)
    b.Matlab(字符串)
    12.Python(装饰器)
    11.Python(生成器)
    10.Python(高级特性)
  • 原文地址:https://www.cnblogs.com/lhp-1992/p/4617331.html
Copyright © 2011-2022 走看看