zoukankan      html  css  js  c++  java
  • [IOS] iphone开发之[美化按钮]

    美化按钮

    //添加一个button,美化按钮
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame = CGRectMake(40, 300, 100, 30);

    UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"];
    UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    //[btn1 setImage:stretchableButtonImageNormal forState:UIControlStateNormal];
    [btn1 setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal]; //set backgroundImage:

    UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"];
    UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    [btn1 setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];

    [self.view addSubview:btn1];

    解说一下:whiteButton.png    blueButton.png  图片在苹果官方网站提供的DEMO:UICatalog中可以找到。

  • 相关阅读:
    创建FLASK,同步docker
    FLASK Buleprint
    restful api
    Angular JS
    线程日志
    将项目部署到linux下的docker容器中
    安装和卸载docker
    学习目录总编
    Ansible
    装饰器
  • 原文地址:https://www.cnblogs.com/iphone520/p/2209844.html
Copyright © 2011-2022 走看看