星空网 > 软件开发 > 操作系统

【代码笔记】点击任何处,显示出红色的UIView

一,效果图。

【代码笔记】点击任何处,显示出红色的UIViewimages/loading.gif' data-original="http://images2015.cnblogs.com/blog/337518/201510/337518-20151015102437194-1503584201.jpg" width="217" height="400" />

二,工程图。

【代码笔记】点击任何处,显示出红色的UIView

三,代码。

RootViewController.h

【代码笔记】点击任何处,显示出红色的UIView
#import <UIKit/UIKit.h>//头文件#import "MoreView.h"@interface RootViewController : UIViewController{  //是否点击  BOOL isSwitch;  //红色UIView界面  MoreView *moreView;}@end
【代码笔记】点击任何处,显示出红色的UIView

 

RootViewController.m

【代码笔记】点击任何处,显示出红色的UIView
//点击任何处,显示出红色的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;  }  }
【代码笔记】点击任何处,显示出红色的UIView

 

MoreView.h

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

 

MoreView.m

【代码笔记】点击任何处,显示出红色的UIView
#import "MoreView.h"@implementation MoreView- (id)initWithFrame:(CGRect)frame{  self = [super initWithFrame:frame];  if (self) {    // Initialization code        //设计背景色为红色    self.backgroundColor=[UIColor redColor];  }  return self;}@end
【代码笔记】点击任何处,显示出红色的UIView

 

 


 

原标题:【代码笔记】点击任何处,显示出红色的UIView

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

快递到泰国多少钱:https://www.goluckyvip.com/tag/103705.html
快递发泰国要找什么快递公司:https://www.goluckyvip.com/tag/103706.html
什么快递能发泰国:https://www.goluckyvip.com/tag/103707.html
国内寄到泰国快递要多少钱:https://www.goluckyvip.com/tag/103708.html
快递到泰国的费用:https://www.goluckyvip.com/tag/103709.html
外贸技巧:https://www.goluckyvip.com/tag/10371.html
TikTok,数据观察与竞品分析的关键 :https://www.xlkjsw.com/news/92276.html
沃尔玛崛起,会撼动亚马逊的地位吗?:https://www.kjdsnews.com/a/1842193.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流