moveshow-监听手指位置趣味小程序
2016-04-26 18:09
417 查看
突发奇想想要在公司的应用上添加一个原本在网页上的效果,就是手指滑动到某一个图标上,没有点击就会显示一个效果,可能是一段文字,或者是图标的特效展示。具体的就像是mac系统下方那个导航一样,随着手指的滑动而变大缩小。
很简单的应用,也没花几分钟时间,但是觉得很有意思可能对于新手来说,可以顺便看看touch捕捉事件函数
应该是不需要上传源代码的。。关键代码就几行
@interface ViewController : UIViewController { CGPoint beginPoint; CGPoint nowPoint; BOOL isInButton; } @property (strong,nonatomic) IBOutlet UIButton *mButton;
- (void)viewDidLoad { [super viewDidLoad]; isInButton = YES; // Do any additional setup after loading the view, typically from a nib. } - (IBAction)buttonclick:(id)sender { NSLog(@"button tap"); } - (void)shownslog { if (isInButton) { [mButton setBackgroundImage:[UIImage imageNamed:@"meinv.jpg"] forState:UIControlStateNormal]; NSLog(@"move in button"); }else{ [mButton setBackgroundImage:[UIImage imageNamed:@"images.jpeg"] forState:UIControlStateNormal]; NSLog(@"move out button"); }
} - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; beginPoint = [touch locationInView:self.view]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; nowPoint = [touch locationInView:self.view]; if (nowPoint.x <314&&nowPoint.x>6&&nowPoint.y>90&&nowPoint.y<313) { if (!isInButton) { isInButton = YES; [self shownslog]; } } else { if (isInButton) { isInButton = NO; [self shownslog]; } } } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if (isInButton) { isInButton = NO; [self shownslog]; } }
代码稍后会上传到cocoachina。关键字:moveshow
很简单的应用,也没花几分钟时间,但是觉得很有意思可能对于新手来说,可以顺便看看touch捕捉事件函数
应该是不需要上传源代码的。。关键代码就几行
@interface ViewController : UIViewController { CGPoint beginPoint; CGPoint nowPoint; BOOL isInButton; } @property (strong,nonatomic) IBOutlet UIButton *mButton;
- (void)viewDidLoad { [super viewDidLoad]; isInButton = YES; // Do any additional setup after loading the view, typically from a nib. } - (IBAction)buttonclick:(id)sender { NSLog(@"button tap"); } - (void)shownslog { if (isInButton) { [mButton setBackgroundImage:[UIImage imageNamed:@"meinv.jpg"] forState:UIControlStateNormal]; NSLog(@"move in button"); }else{ [mButton setBackgroundImage:[UIImage imageNamed:@"images.jpeg"] forState:UIControlStateNormal]; NSLog(@"move out button"); }
} - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; beginPoint = [touch locationInView:self.view]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; nowPoint = [touch locationInView:self.view]; if (nowPoint.x <314&&nowPoint.x>6&&nowPoint.y>90&&nowPoint.y<313) { if (!isInButton) { isInButton = YES; [self shownslog]; } } else { if (isInButton) { isInButton = NO; [self shownslog]; } } } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if (isInButton) { isInButton = NO; [self shownslog]; } }
代码稍后会上传到cocoachina。关键字:moveshow
相关文章推荐
- Android小程序-Walker注册页面(四)
- 微信第三方登录
- ios使用友盟分享到QQ/微信时时如何判断手机上是否安装了QQ以及微信的客户端
- 微信主动发送消息到客户端
- 支付宝支付 微信支付 SDK的集成教程
- 微信与支付宝钱包的竞争分析
- C#开发微信门户及应用(36)--微信卡劵管理的封装操作
- 干货二:微信SDK-分享初探-更新中
- 一个聊天小程序
- android中微信、朋友圈分享无回调的问题
- iso android a标签css :active 在微信或app内嵌不起作用解决方案
- 第三方登录——QQ、微信、新浪微博和百度登录
- 仿微信朋友圈动态内容全文显示与收起实现
- .Net实现微信公众平台开发接口(三) 之 “信息回复”
- .Net实现微信公众平台开发接口(一) 之 “微信开发配置”
- 获取微信的access_tokey,处理json格式的数据
- .Net实现微信公众平台开发接口(二) 之 “获取access_token”
- 微信--H5非微信内浏览器支付
- [转]html5 video在安卓大部分浏览器包括微信最顶层的问题
- 公众号里腾讯视频下载