欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

UIButton 图片的 平铺。 博客分类: iOS UIButtonbutton按钮平铺背景 

程序员文章站 2024-03-25 15:27:34
...

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 19, 300, 41) title:NSLocalizedString(@"DoneButton", "") textColor:ButtonWhiteColor backgroundImageNames:nil target:self action:@selector(clickCodeButton)];

 

    UIEdgeInsets insets = UIEdgeInsetsMake(0, 8, 0, 8);

    UIImage *tempImage = [UIImage imageNamed:@"button_logout_bg"];

    UIImage *pressImage = [UIImage imageNamed:@"button_logout_bg_pres"];

    tempImage = [tempImage resizableImageWithCapInsets:insets];

    pressImage = [pressImage resizableImageWithCapInsets:insets];

 

    [button setBackgroundImage:tempImage forState:UIControlStateNormal];

    [button setBackgroundImage:pressImage forState:UIControlStateHighlighted];

    [footerView addSubview:button];

 

    [button release];