创建硬自定义按钮

时间:2012-10-24 12:11:58

标签: objective-c ios uibutton

我无法弄清楚如何构建此按钮。我需要帮助来创建它,请注意,当按钮处于活动状态时,条带不会被绘制。我应该使用哪些元素?

在链接上你可以看这个按钮

http://i.stack.imgur.com/0mmJ0.png

    UIButton *clone = [[UIButton alloc] initWithFrame:frame];
    [clone setTitle:strDate forState:UIControlStateNormal];
    [clone setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    clone.frame = CGRectMake(19, post_offer_top*(i-1)+22, 281, 75);
    clone.tag = my_id;
   // [clone setTitle:[[buttons objectAtIndex:i-1] objectForKey:@"title"] forState:UIControlStateNormal];
    clone.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    clone.contentEdgeInsets = UIEdgeInsetsMake(44, 31, 0, 0);
    [clone setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [clone setTitleShadowColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [clone.titleLabel setFont:[UIFont fontWithName:@"PF DinDisplay Pro" size:10]];
    [clone.titleLabel setShadowOffset:CGSizeMake(0.0f, 1.0f)];

任何想法?

1 个答案:

答案 0 :(得分:1)

你应该像这样初始化按钮[UIButton buttonWithType:UIButtonTypeCustom]