2016年01月07日公司项目开发记录

2016年01月07日14:35:00 周四

for 循环创建 Button 如何区分

_actionButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _actionButton.frame = healthView.frame;
        [_actionButton addTarget:self action:@selector(actionButton:) forControlEvents:(UIControlEventTouchUpInside)];
        _actionButton.tag = 100 + i;
        [_actionButton setTitle:@"" forState:(UIControlStateNormal)];
        [_backScrollView addSubview:_actionButton];

之后调用的时候

-(void)actionButton:(UIButton *)button{

    switch (button.tag) {
        case 100:{
            NSLog(@"血压  BP");
          }
            break;
        case 101:{
            NSLog(@"血糖  BG");
          }
            break;
        case 102:{
            NSLog(@"血脂  FA");
          }
            break;

        default:
            break;
    }
}


设置左侧自定义的 textfield

//设置用户名输入框
    _userName_TF = [[UITextField alloc]initWithFrame:CGRectMake(-3,CGRectGetMaxY( userLogo_Image.frame) + 15*SKHeightRate, SKScreenWidth+6, 46*SKHeightRate)];
    _userName_TF.placeholder = @"请输入用户名";
    _userName_TF.borderStyle = UITextBorderStyleRoundedRect;
    _userName_TF.keyboardType = UIKeyboardTypeURL;
    _userName_TF.userInteractionEnabled = YES;
    _userName_TF.font = [UIFont fontWithName:@"Arial" size:14];
    _userName_TF.delegate = self;
    _userName_TF.layer.borderWidth = 1;
    _userName_TF.layer.borderColor = [RGB(204, 204, 204) CGColor];
    _userName_TF.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.view addSubview:_userName_TF];

    UIView *viewName = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 64*SKWidthRate, 46*SKHeightRate)];
    viewName.backgroundColor = [UIColor clearColor];
    UIImageView *userNameView = [[UIImageView alloc]initWithFrame:CGRectMake(30*SKWidthRate, 10*SKHeightRate, 20*SKHeightRate, 26*SKHeightRate)];
    userNameView.image = [[UIImage imageNamed:@"手机"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [viewName addSubview:userNameView];
    _userName_TF.leftView = viewName;
   _userName_TF.leftViewMode = UITextFieldViewModeAlways;


更多精彩文章,尽在我的公众号.



你可能感兴趣的:(个人项目开发记录)