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

【代码笔记】点击任何处,显示出红色的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/13253.html
跨境电商女生:https://www.goluckyvip.com/tag/13254.html
Purplle:https://www.goluckyvip.com/tag/13256.html
泳装市场:https://www.goluckyvip.com/tag/13257.html
泳装热销款式:https://www.goluckyvip.com/tag/13258.html
斋月促销:https://www.goluckyvip.com/tag/13259.html
三亚有哪些酒店值得入住?:https://www.vstour.cn/a/366173.html
零售晚报:丽人丽妆2023年扭亏为盈 玉容初、美壹堂等自有品牌增速超40% :https://www.kjdsnews.com/a/1836649.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流