手势添加

    UILabel *textLabel = [[UILabel alloc] init];

// 红色是 label fram (VFL)

    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-10-[textLabel]-10-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(textLabel)]];

    //V:[titleLabel]-0-[textLabel]-35-|

    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_titleLabel]-0-[textLabel]-(>=40)-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_titleLabel,textLabel)]];

    textLabel.userInteractionEnabled = YES;

    UITapGestureRecognizer* textLabelTag = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(writeButtonClick)];

    [textLabel addGestureRecognizer:textLabelTag];

posted @ 2016-03-29 15:57  徒步阳光855  阅读(138)  评论(0)    收藏  举报