【代码笔记】iOS-点击任何处,显示出红色的UIView
一,效果图。
二,工程图。
三,代码。
RootViewController.h

#import <UIKit/UIKit.h>
//头文件
#import "MoreView.h" @interface RootViewController : UIViewController
{
//是否点击
BOOL isSwitch;
//红色UIView界面
MoreView *moreView;
}
@end

RootViewController.m

//点击任何处,显示出红色的UIView
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if (isSwitch) {
[moreView removeFromSuperview];
isSwitch=NO;
}else{
moreView=[[MoreView alloc]initWithFrame:CGRectMake(10, 100, 200, 50)];
[self.view addSubview:moreView];
isSwitch=YES;
} }

MoreView.h
#import <UIKit/UIKit.h> @interface MoreView : UIView @end
MoreView.m

#import "MoreView.h" @implementation MoreView - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code //设计背景色为红色
self.backgroundColor=[UIColor redColor];
}
return self;
} @end

【代码笔记】iOS-点击任何处,显示出红色的UIView的更多相关文章
- 【代码笔记】iOS-点击城市中的tableView跳转到旅游景点的tableView,下面会有“显示”更多。
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- 【代码笔记】iOS-在导航栏中显示等待对话框
一,效果图. 二,代码. ViewController.m #import "ViewController.h" @interface ViewController () @end ...
- 【代码笔记】iOS-点击搜索按钮,或放大镜后都会弹出搜索框
一, 效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "CLHSearchBar.h ...
- 【代码笔记】iOS-点击cell时候的动画翻转
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- 【代码笔记】iOS-点击顶点处,弹出另一个小的界面
一,效果图. 二,文件目录. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewControlle ...
- 【代码笔记】iOS-点击一个按钮会出现多个按钮的动画效果
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- 【代码笔记】iOS-点击任何处,出现城市
一,效果图. 二,工程目录. 三,代码. //点击任何处,出现城市 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { ...
- 【代码笔记】iOS-点击出现选择框
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- 【代码笔记】iOS-点击一个button,出6个button
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> //加入头文件 #import "DCPathB ...
随机推荐
- c# 指定的存储区提供程序在配置中找不到,或者无效
<system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite"/ ...
- android布局属性详解
RelativeLayout用到的一些重要的属性: 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 android:layout_cen ...
- QTableWidget的美化
FriendTable->setFrameShape(QFrame::NoFrame); //设置边框 FriendTable->setHorizontalHeaderLabels( ...
- html5学习笔记(3)--主题结构元素-1
Article元素 以下为对应代码: <!DOCTYPE html> <html> <head lang="en"> <meta char ...
- Tomcat Server Timeouts属性的设置
在启动Tomcat Server时,经常会出现启动时间过长的错误,如下图所示(为了方便截图,Start Timeout被设置为5秒钟,一般为45秒钟). 双击Tomcat v7.0 Server at ...
- Java程序,JDK的安装、环境的配置
打开文件包,找到jdk-8u111-windows-x64 (64位) 双击打开安装界面 路径自行更改;(不可使用中文字段)新建一个文件夹放后面这个安装包 二.设置环境变量 右键我的电脑-属性-高 ...
- python 学习笔记9(面向对象)
面向过程.函数式.面向对象 面向过程:根据业务逻辑从上到下写垒代码 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象(Object Oriented Programmin ...
- Android填坑系列:Android JSONObject 中对key-value为null的特殊处理
在与服务端通过JSON格式进行交互过程中,不同版本的JSON库在对于key-value为null情况上的处理不同. Android自带的org.json对key-value都要求不能为null,对于必 ...
- Xdebug文档(一)基本特性
基本属性(参数) xdebug.default_enable 类型: boolean,默认值: 1 这是xdebug的基本设置,默认在调试跟踪时显示错误信息.可以使用xdebug_disable()函 ...
- JDBC详解
一.相关概念 1.什么是JDBC JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它 ...