zoukankan      html  css  js  c++  java
  • ios UIButton改背景

    以下orangeButton.png与orangeButtonHighlight.png分别用于按钮平常状态和被点击时的状态:

    UIImage *buttonImage = [[UIImage imageNamed:@"orangeButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)];
    UIImage *buttonImageHighlight = [[UIImage imageNamed:@"orangeButtonHighlight.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)];
     
    // Set the background for any states you plan to use
    [saveButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
    [saveButton setBackgroundImage:buttonImageHighlight forState:UIControlStateHighlighted];

    代码创建一个UIButton:

    UIButton *btnClear = [[UIButton alloc] init];
    btnClear = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
    btnClear.frame = CGRectMake(115, 200, 90, 40);
    [btnClear setTitle:@"Clear" forState:UIControlStateNormal];
    [btnClear setBackgroundImage:[UIImage imageNamed:@"blue_button.png"] forState:UIControlStateNormal];
    [btnClear addTarget:self action:@selector(clearAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btnClear];
  • 相关阅读:
    【必备】史上最全的浏览器 CSS & JS Hack 手册(转)
    iScroll4.2.5中的无法滑动或点击的解决方案(转)
    无障碍网页设计(WCAG2.0)
    大小端
    TCP报文结构
    A*
    shell中uniq与sort -u 两种去重的对别
    login流程
    类模板成员函数
    game 角色相关记录
  • 原文地址:https://www.cnblogs.com/edgarli/p/3270804.html
Copyright © 2011-2022 走看看