Giter VIP home page Giter VIP logo

ios-----'s Introduction

简书:http://www.jianshu.com/p/cbc9555ed91e

iOS开发范例-按钮类-会发光的按钮 --------------- 实例1 发光的按钮 ---------------

实例描述 本实例实现的功能是当用户点击按钮时,按钮会发光。以这样的方式提示用户已经点击按钮了。运行静态图请看图1.1,动态图请看1.2所示:

图1.1 静态图

图1.2 动态图

实现过程: 当用户点击界面上的按钮时,按钮发光,当按钮没有被单击时,不会发光。具体实现步骤如下。

(1) 创建一个项目,命名为"发光按钮"。 (2) 打开Main.stroyboard文件,对ViewController视图控制器界面进行设计。如图1.3所示: (在Main.stroyboard中拖入名为Click的按钮,并设置合适大小)

图1.3 对ViewController视图控制器的设计界面效果 (3) 打开ViewController.h文件,编写代码,进行按钮click的属性声明和方法实现。 需要添加的视图、控件以及对他们的设置如表1-1所示。

表1-1 视图、控件设置 (4) 打开ViewController.m文件,编写代码,实现单击按钮时,按钮发光。程序代码如下:

点击事件-发光

要单击按钮,使按钮发光。 可以使用UIButton的 showsTouchWhenHighlighted 属性进行判断。

在代码中,

YES-->点击时发光 NO -->点击时不发光 默认-->不发光

ios-----'s People

Contributors

renzhengyang avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.