Android程序开发之给背景图加上移动的手势_Android

一,工程图。

二,效果图。

三,代码。

RootViewController.h

#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController
<UIGestureRecognizerDelegate>
@end 

RootViewController.m

#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
//增加背景图
[self addView];
}
#pragma -mark -functions
//背景图
-(void)addView
{
//红色的背景图
UIView *parentView=[[UIView alloc]initWithFrame:CGRectMake(50, 100, 200, 200)];
parentView.backgroundColor=[UIColor redColor];
[self.view addSubview:parentView];
[parentView setUserInteractionEnabled:YES];
//移动的手势
UIPanGestureRecognizer *panRcognize=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
panRcognize.delegate=self;
[panRcognize setEnabled:YES];
[panRcognize delaysTouchesEnded];
[panRcognize cancelsTouchesInView];
[parentView addGestureRecognizer:panRcognize];
}
#pragma UIGestureRecognizer Handles
- (void)handlePan:(UIPanGestureRecognizer *)recognizer {
NSLog(@"--移动的手势-----");
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

以上代码是有关Android程序开发之给背景图加上移动的手势的全部内容,希望对大家有所帮助!

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索背景图移动手势
android 手势密码开发、android小程序开发、android应用程序开发、android程序开发、android开发退出程序,以便于您获取更多的相关知识。

时间: 2024-08-02 09:48:18

Android程序开发之给背景图加上移动的手势_Android的相关文章

Android程序开发之给背景图加上移动的手势

一,工程图. 二,效果图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController <UIGestureRecognizerDelegate> @end RootViewController.m #import "RootViewController.h" @interface RootViewController ()

Android程序开发仿新版QQ锁屏下弹窗功能_Android

新版的qq,可以在锁屏下弹窗显示qq消息,正好目前在做的项目也需要这一功能.经过各种试验和资料查找,终于实现,过程不难,但是却有一些地方需要注意. 下面是实现过程. 1.使用Activity,而不是View QQ的弹窗一开始我以为是悬浮View,用WindowManager去添加,但是无论如何就是不显示,后来在朋友提示下换成Activity来实现,在锁屏状态下就能弹窗了. 2.Activity的设置 Activity需要进行以下设置,才可以在锁屏状态下弹窗. 首先是onCreate方法,需要添加

Android程序开发之防止密码输入错误 密码明文显示功能_Android

在使用App的时候,首次登录都需要用户输入密码的,有些朋友为了安全起见密码设置的比较长,导致很多次密码都输入错误,严重影响了用户体验效果.这一点移动开发者做好了准备工作,因为手机的私密性比较强,在输入密码的时候,可以显示输入,增强准确性,提升用户体验度.这当然要付出代价的,需要额外的代码编写功能.下面通过本文给大家介绍如何编写密码明文显示的功能,仅供参考. 本文源码的GitHub下载地址 要点 (1) 重写EditText, 添加提示密码显示和隐藏的图片. (2) 判断点击位置, 切换EditT

Android程序开发之使用Design包实现QQ动画侧滑效果和滑动菜单导航_Android

Google在2015的IO大会上,给我们带来了更加详细的Material Design设计规范,同时,也给我们带来了全新的Android Design Support Library,在这个support库里面,Google给我们提供了更加规范的MD设计风格的控件.最重要的是,Android Design Support Library的兼容性更广,直接可以向下兼容到Android 2.2.这不得不说是一个良心之作. 使用方法很简单,只需要添加一句依赖 compile 'com.android

Android程序开发ListView+Json+异步网络图片加载+滚动翻页的例子(图片能缓存,图片不错乱)_Android

例子中用于解析Json的Gson请自己Google下载 主Activity: package COM.Example.Main; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import COM.Example.Main.R; import COM.Example.Main.stringG

Android程序开发之自定义设置TabHost,TabWidget样式_Android

先看效果: 京东商城底部菜单栏 新浪微博底部菜单栏 本次学习效果图: 第一,主布局文件(启动页main.xml,位于res/layout目录下)代码 <?xml version="." encoding="utf-"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_paren

Android程序开发之获取汉字的首字母_Android

获取一个汉字的拼音首字母. GB码两个字节分别减去160,转换成10进制码组合就可以得到区位码例如汉字"你"的GB码是0xC4/0xE3,分别减去0xA0(160)就是0x24/0x430x24转成10进制就是36,0x43是67,那么它的区位码就是3667,在对照表中读音为'n'. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&quo

Android程序开发之获取汉字的首字母

获取一个汉字的拼音首字母. GB码两个字节分别减去160,转换成10进制码组合就可以得到区位码例如汉字"你"的GB码是0xC4/0xE3,分别减去0xA0(160)就是0x24/0x430x24转成10进制就是36,0x43是67,那么它的区位码就是3667,在对照表中读音为'n'. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&quo

Android程序开发中单选按钮(RadioGroup)的使用详解

在还没给大家介绍单选按钮(RadioGroup)的使用,先给大家展示下效果图吧: xml文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_heig