一,效果图。

二,工程图。

三,代码。

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的更多相关文章

  1. 【代码笔记】iOS-点击城市中的tableView跳转到旅游景点的tableView,下面会有“显示”更多。

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  2. 【代码笔记】iOS-在导航栏中显示等待对话框

    一,效果图. 二,代码. ViewController.m #import "ViewController.h" @interface ViewController () @end ...

  3. 【代码笔记】iOS-点击搜索按钮,或放大镜后都会弹出搜索框

    一, 效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "CLHSearchBar.h ...

  4. 【代码笔记】iOS-点击cell时候的动画翻转

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  5. 【代码笔记】iOS-点击顶点处,弹出另一个小的界面

    一,效果图. 二,文件目录. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewControlle ...

  6. 【代码笔记】iOS-点击一个按钮会出现多个按钮的动画效果

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  7. 【代码笔记】iOS-点击任何处,出现城市

    一,效果图. 二,工程目录. 三,代码. //点击任何处,出现城市 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { ...

  8. 【代码笔记】iOS-点击出现选择框

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...

  9. 【代码笔记】iOS-点击一个button,出6个button

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> //加入头文件 #import "DCPathB ...

随机推荐

  1. 基于HT的CSG功能构建HTML5的3D书架

    构造实体几何CSG全称Constructive solid geometry,是3D计算机图形学中构建模型的常用技术,可通过合并Union.相减Subtraction和相交Intersction的三种 ...

  2. 使用Spark分析拉勾网招聘信息(三): BMR 入门

    简述 本文,意在以最小的篇幅,来帮助对大数据和Spark感兴趣的小伙伴,能尽快搭建一个可用的Spark开发环境.力求言简意赅.文章,不敢自称BMR的最佳实践,但绝对可以帮助初学者,迅速入门,能够专心于 ...

  3. SQL--类型转换

    Convert函数和Cast函数都是转化函数,效果是一样的. cast函数,转化,如果转化之后,年龄还是Null的话,就显示为“未知” Convert函数和Cast函数都是转化函数,效果是一样的.

  4. Windows Server 2016正式版14393英文版ISO镜像下载:_X64FRE_ZH-CN.ISO

    http://care.dlservice.microsoft.com/dl/download/F/8/3/F83C7D26-787A-4F43-82B0-7C7BF8A12791/14393.0.1 ...

  5. JS实现日程安排 日程安排插件

    代码: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmpWeekPla ...

  6. python的metaclass

    元类一般用于创建类.在执行类定义时,解释器必须要知道这个类的正确的元类.解释器会先寻找类属性__metaclass__,如果此属性存在,就将这个属性赋值给此类作为它的元类.如果此属性没有定义,它会向上 ...

  7. JsonConvert 使用注意事项之 Serializable

    1.使用NuGet安装Newtonsoft.Json. 2.创建需要序列化的类. public class Person { public string Name{get;set;} public i ...

  8. 为什么很多APP要有启动页面

    我们启动APP时,一般都会是一张含有LOGO的图片.这张图片叫做启动页面. 这个启动页面是必须.一定需要的吗?有什么作用?   这是苹果官方对于iOS启动页的设计说明:   为了增强应用程序启动时的用 ...

  9. MEF入门之不求甚解,但力求简单能讲明白(一)

    起因:工作需要针对不同类型的文件做不同的处理.打个比方,txt文件,直接打印,doc文件,直接发email,jpg文件,上传xxx相册站点. 其实这个问题在学习最基本的工厂模式的时候早已经解决了,稍有 ...

  10. 将AJAX返回值纵向排序赋值给Table标签

    /*下面是所有拼接这个表的代码*/ 1 function HandelAjaxReturnDataForContentTable(data) { var shareHtml = "" ...