iOS 键盘视图 CLKeyboardOffsetView

码农软件 · 软件分类 · 键盘(Keyboard) · 2019-07-15 08:14:44

软件介绍

CLKeyboardOffsetView 是键盘补偿视图工具,为了避免弹出的键盘遮挡输入框,向上移动视图 。

image

使用方法:

#import "UIView+CLKeyboardOffsetView.h"
- (void)viewDidAppear:(BOOL)animated
{
  [super viewDidAppear:animated];
  // 打开键盘补偿视图
  [self.view openKeyboardOffsetView];
  self.view.keyboardGap = 10; // 如果需要自定义键盘与第一响应者之间的间隙,则设置此属性,默认为5
}
- (void)viewDidDisappear:(BOOL)animated
{
  [super viewDidDisappear:animated];
  // 关闭键盘补偿视图
  [self.view closeKeyboardOffsetView];
}
如果需要自定义视图向上移动的高度,则使用代理 
<CLKeyboardOffsetViewDelegate>
self.view.keyboardOffsetViewDelegate = self;
并添加代理方法
/**
 *  弹出键盘时,自定义视图向上移动的高度
 *
 *  @param firstResponder 第一响应者
 *  @param keyboardHeight 当前弹出键盘的高度
 *  @param offsetHeight   默认偏移高度
 *
 *  @return 视图向上移动的高度
 */
- (CGFloat)offsetViewHeightWithFirstResponder:(UIView *)firstResponder
                               keyboardHeight:(CGFloat)keyboardHeight
                                 offsetHeight:(CGFloat)offsetHeight
{
    if ([firstResponder isEqual:_testTextField])
    {
        return keyboardHeight;
    }
    return offsetHeight;
}

本文地址:https://www.codercto.com/soft/d/10165.html

PHP and MySQL Web Development (3rd Edition) (Developer's Library

PHP and MySQL Web Development (3rd Edition) (Developer's Library

Luke Welling、Laura Thomson / Sams / 2004-09-29 / USD 49.99

We've taken the best and made it even better. The third edition of the best-selling PHP and MySQL Web Development has been updated to include material and code on MySQL 5, PHP 5 and on PHPs object mod......一起来看看 《PHP and MySQL Web Development (3rd Edition) (Developer's Library》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具