XMG 抽屉效果

2024-06-24 10:48
文章标签 xmg 抽屉 效果

本文主要是介绍XMG 抽屉效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.比如说我创建了3个View

-(void)viewDidLoad{

 [ super viewDidLoad];

[self setUpChild] ;

  

     UIPanGestureRecognizer *pan=[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)];

     [ self.view addGestureRecognizer:pan]

   

  

    // Observer:观察者 谁想监听

    // KeyPath:监听的属性

    // options:监听新值的改变


    [_mainV addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil];

  


}

-

//如果想要监听一个对象的某个属性可以使用KVO

// 只要监听的属性一改变,就会调用观察者的这个方法,通知你有新值

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

{

    NSLog(@"%@",NSStringFromCGRect(_mainV.frame));

    if (_mainV.frame.origin.x > 0) { // 往右边移动,隐藏蓝色的view

        _rightV.hidden = YES;

    }else if (_mainV.frame.origin.x < 0){ // 往左边移动,显示蓝色的view

        _rightV.hidden = NO;

}    


使用KVO之后一定要记得在dealloc方法中移除监听.当对象被销毁的时候移除观察者

-(void)dealloc{

   [_main removeObserve:self keyPath:@"frame"];

}


    


//创建对应的View

- (void)setUpChildView

{

    // left

    UIView *leftV = [[UIView alloc] initWithFrame:self.view.bounds];

    

    leftV.backgroundColor = [UIColor greenColor];

    

    [self.view addSubview:leftV];

    

    _leftV = leftV;

    

    // right

    UIView *rightV = [[UIView alloc] initWithFrame:self.view.bounds];

    

    rightV.backgroundColor = [UIColor blueColor];

    

    [self.view addSubview:rightV];

    

    _rightV = rightV;

    

    // main

    UIView *mainV = [[UIView alloc] initWithFrame:self.view.bounds];

    

    mainV.backgroundColor = [UIColor redColor];

    

    [self.view addSubview:mainV];

    

    _mainV = mainV;

}






这篇关于XMG 抽屉效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1089936

相关文章

以canvas方式绘制粒子背景效果,感觉还可以

这个是看到项目中别人写好的,感觉这种写法效果还可以,就存留记录下 就是这种的背景效果。如果想改背景颜色可以通过canvas.js文件中的fillStyle值改。 附上demo下载地址。 https://download.csdn.net/download/u012138137/11249872

echarts省份标注加散点效果

这个是安徽的效果图,鼠标移到红色标注或者对应的市区位置都会显示对应的数值。 先直接上代码: import anhuiMapJson from './anhui.json'getCoords: function(city) {var res = [];if (city != null) {for (var c in this.cityMap.features) {if (this.cityMa

XMG 绘制形状

1. 除非是绘制曲线直接使用原生的。如果绘制形状直接使用UIBezerPath  2. 命名原则,类方法以类名开头 UIBezierPath bezierPathWithRect 3.圆角半径 画圆的大小 以每个顶点为圆心。给定的半径为半径画一个1/4圆。把周边的给切掉 4.只有封闭的形状调用这个方法才有用 [path fill] 5. stroke 描边一下

XMG Quartz2D的简单使用

// //  Quratz2DView.m //  Quartz2D // //  Created by 王宁 on 16/5/6. //  Copyright © 2016年 ylshmacmini. All rights reserved. // #import "Quratz2DView.h" //Quartz@2D是一个二维绘图引擎,同时支

XMG 自动提示宏 #define keyPath(objc,keyPath) @(((void)objc.keyPath,#keyPath));

1. int a=((void)5,4)  C语言逗号表达式默认会取右边的内容 如果不写void的话 a会被报警告,写上void标明请忽略左边的内容 插曲刚才弄得,已经上线的苹果产品如果需要下架的话,点击 价格与销售范围,然后点击下架。这个产品就会在AppStore 中移除。如果想再让改产品重新在Apple store中显示,那么再次让他上线就可以了。但是会有一定的时间延迟 /

XMG 各种手势

1. - (void)setUpTap {     // 创建点按手势     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];     tap.numberOfTapsRequired=2;     tap.deleg

XMG 常用的手势

// 创建点按手势     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];    tap.numberOfTabsRequired=2; //点击的次数

XMG 触摸事件的处理过程

1.自己本身并不处理,顺着响应者链条向上传递,将事件交给响应者进行处理 2.touches默认做法:把事件传递到上一个响应者 3. super是父类不是父控件

XMG 重写- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event方法

//重写这个方法,来完成一些指定的事件。比如说按钮被遮到下面了,但是我想让点击到这块区域的时候让按钮去相应点击 - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {     // 当前坐标系上的点转换到按钮上的点     CGPoint btnP = [self convertPoint:point toVi

XMG xib中不属于一个类的控件,拖线到指定的类中

1.比如我现在有一个view绑定为GreenView,我们按住control向类里面拖线的方式想要达到目的,显然拖不进去。例图如下 那么我们此时还想要达到目的,就需要自己去GreenView的类内部去写IBo 然后这面连接起来 2.第二,大哥郝良建给做的扩展 可以在.h或者.m中写一个NSObject的属性 然后在xib中对应的位置创建一个NSObject的属性