【实现点击下载按钮功能 Objective-C语言】

这篇博客详细介绍了如何在Objective-C中实现点击下载按钮的功能,包括给按钮注册单击事件、禁用按钮、显示下载提示以及使用动画实现提示框的渐显渐隐效果。通过修改按钮的属性和利用UIView的动画方法,实现了用户友好的交互体验。
摘要由CSDN通过智能技术生成

一、实现点击下载按钮功能,

1.接下来,我们再实现另外一个功能,是什么,点击下载按钮吧:

点击下载按钮

点击下载按钮,是不是要有效果啊,

就是给大家实现这个功能,

首先,我们要实现单击这个效果,是不是要给按钮注册单击事件吧,

请问,这个按钮在哪里啊,是在控制器里面吗,不是,是不是在我们这个自定义View的类里面,TestAppView这个类里面,

这个xib里面,是不是有这个按钮,我们希望给这个下载按钮注册一个单击事件吧,怎么给它注册单击事件,通过拖线的方式,是不是可以给它注册一个单击事件,

所以,我们打开TestAppVIew.xib文件,选中这个“下载”按钮,点开辅助编辑器,在辅助编辑器里,打开TestAppView.m文件,

到这个里面,之前拖了这个按钮的一个属性:

@property(nonatomic,weak) IBOutlet UIButton *btnDownload;

我们现在,再给它拖一个Action,单击事件,

选中,右键,Touch Up Inside,

输入6个参数:

1)第一个参数:Connection,给个Action,

2)第二个参数:Object,不选择App View,

3)第三个参数:Name,给个,叫什么,btnDownloadClick,可以吧,这个按钮的Click事件,

4)第四个参数,Type,给个id,

5)第五个参数,Event,给个Touch Up Inside,

6)第六个参数,Argument,给个None,

点击Connect,自动生成了我们这个按钮的单击事件:

- (IBAction)btnDownloadClick;

然后打开我们这个自定义View里面,在TestAppView.m文件里:

按钮是不是有个单击事件了吧,

ok,在这个下载按钮的单击事件里面,要干什么,

//下载按钮的单击事件:

- (IBAction)btnDownloadClick{

//当一点它,首先是不是要把这个按钮禁用,禁用完毕以后,是不是要弹出一个框框来,框框里面,是不是要显示“正在下载”或者什么东西吧,

//等会儿,这个框框,是不是要慢慢隐藏掉吧,

//所以说,第一步,让当前被点击的按钮,禁用,

//第二步,让它弹出一个框框来,

//1.禁用当前被点击的按钮,

//2.弹出一个消息提醒框(这个消息提醒框其实就是一个UILabel,

//那么,接下来,有一点,你要点击这个按钮,是不是要让当前被点击的按钮禁用掉啊,

//那么怎么获取当前被点击的那个按钮呢,

//其实咱们刚才应该怎么样啊,这儿是不是应该传这个参数啊:

//- (IBAction)btnDownloadClick:(UIButton *)sender;

//刚才咱们拖线的时候,是不是我没有选这个参数啊,

//我们再重新拖一下这个按钮的线,选上这个参数:

//设置6个参数:

//1)第一个参数:Connection,给个Action,

//2)第二个参数:Object,不勾选App View,

//3)第三个参数:Name,给个btnDownloadClick,

//4)第四个参数:Type,给个UIButton,这儿是不是要选择中间这个参数类型,是什么类型,Button类型吧,表示这是不是要把当前点击的这个按钮传过去,

//5)第五个参数:Event,给个Touch Up Inside,

//6)第六个参数:Argument,给个Sender,这个按钮的名字叫做Sender,

//点击Connect,自动生成了下面这个方法:

//- (IBAction)btnDownloadClick:(UIButton *)sender;

//这样的话,在这个单击事件里面,当前点击的是哪个按钮,这个sender表示的就是当前被点击的按钮吧,

//下载按钮的单击事件

- (IBAction)btnDownloadClick:(UIButton *)sender{

//1.禁用当前被点击的按钮

//2.弹出一个消息

Pro Objective-C The Objective-C programming language continues to grow in popularity and usage because of the power and ease-of-use of the language itself, along with the numerous features that continue to be added to the platform. If you have a basic knowledge of the language and want to further your expertise, Pro Objective-C is the book for you. Pro Objective-C provides an in-depth, comprehensive guide to the language, its runtime, and key API’s. It explains the key concepts of Objective-C in a clear, easy to understand manner, and also provides detailed coverage of its more complex features. In addition, the book includes numerous practical examples--code excerpts and complete applications--that demonstrate how to apply in code what you’re learning. The book begins with an exploration of Objective-C's basic features and key language elements. After reviewing the basics, it proceeds with an in-depth examination of the Objective-C dynamic programming features and runtime system. Next the book covers the Foundation Framework, the base layer of APIs that can be used for any Objective-C program. Finally, new and advanced features of Objective-C are introduced and shown how they make the Objective-C language even more powerful and expressive. Each topic is covered thoroughly and is packed with the details you need to develop Objective-C code effectively. The most important features are given in-depth treatment, and each chapter contains numerous examples that demonstrate both the power and the subtlety of Objective-C. Start reading Pro Objective-C and begin developing high-quality, professional apps on the OS X and iOS platforms using the Objective-C programming language! What you’ll learn Objective-C fundamentals and key language elements Objective-C runtime system Foundation Framework APIs Objective-C advanced language features Xcode Essentials Debugging with LLDB Who this book is forThis book is geared towards intermediate to advanced developers who already have some Objective-C experience and want pro-level coverage of the language, including advanced Objective-C features, recent additions to the language, and practical usage of its core frameworks and APIs. It's also great for those developers not familiar with Objective-C that have done some C programming and also understand object-oriented programming concepts.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

清风清晨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值