RComposeBar 1.0.1

RComposeBar 1.0.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2016年8月

Rapple UI Animator 维护。



  • 作者:
  • Rajeev Prasad

RComposeBar

RComposeBar 是一个用户友好的聊天消息编写栏,可以编写任何类型的消息。RComposeBar 为用户提供更多灵活性,使用户可以使用希望用到的任何信息/数据编写消息。

要求

  • Xcode 7.3 或更高版本
  • iOS 8.0 或更高版本
  • ARC

安装

RComposeBar 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile

pod 'RComposeBar'

使用方法

首先将 RComposebar 导入到您的类中 #import <RComposeBar/RComposeBar.h>

然后您可以在类内配置 RComposeBar。

设置全局属性以保持 composeBar 和 composeBar 容器的状态。我们在屏幕底部放置一个工具栏来放置 composeBar。

@property (strong, nonatomic) RComposeBar *composeBar; // RComposeBaee
@property (strong, nonatomic) IBOutlet UIToolbar *toolbar;  // Any view to hold the compose bar (UIToolbar is used here)

这个容器视图(工具栏)的高度不需要手动调整,但如果您想移除改变 autoLayout 值的默认动画,您可以添加一个 IBOutlet 并在相关的代理方法中手动设置高度值。

@property (strong, nonatomic) IBOutlet NSLayoutConstraint *toolbarHeight;

然后实例化和设置 composeBar

_composeBar = [[RComposeBar alloc] initWithContainer:_toolbar delegate:self];
// _composeBar.delegate = self;
_composeBar.dataSource = self;
// _composeBar.sendTitle = @"Post"; // change button text
_composeBar.leftButtonImage = [UIImage imageNamed:@"more"];
[_composeBar setRightButtonWithTag:1 image:[UIImage imageNamed:@"mic"] backToKBImage:[UIImage imageNamed:@"kb"]];
// [_composeBar setRightButtonWithTag:AUDIO_RECORDER text:@"Mic" backToKBYText:@"KB"]; // text instead of an image
_composeBar.maxHeight = 200; // max height that compose bar can grow
_composeBar.placeholder = @"whats on your mind";

然后实现 RComposeBarDelegate 的必需代理方法,该方法是使 composeBar 无缝工作所必需的

-(void)composeBarSendDidTapped:(NSString *)text {
    // this method will called with send button tapped (only if textbox text available)
    [_chatList addObject:@{kText : text, kMine : @(1)}];
    [_table reloadData];
}

-(void)composeBarHeightDidChange:(CGFloat)height {
    // optional - layout engine will animate this change - if you wanna remove animation add this
    _toolbarHeight.constant = height; 
}

RComposeBarDelegate (可选)

- (void) composeBarLeftButtonTapped {
    /** Left button tapped */
}

- (void) composeBarRightButtomTapped:(NSInteger)tag {
    /** Right button tapped (only when textbox is empty)*/
    /** Tag can be used to identify the purpose of the right button - can be used for multiple purposses */
}

- (void) composeBarLocationSelected {
    /** Location selected */
}

- (void) composeBarTextDidChanged:(NSString *)text {
    /** Text value changed in compose bar */
}

- (void) deleteComposeBarItemAtIndex:(NSInteger)index {
    /** Item at index should be deleted */
}

- (void) selecteComposeBarItemAtIndex:(NSInteger)index {
    /** Item at index is selected */
}

- (void) deleteComposeBarLocation {
    /** Location should be deleted */
}

- (void) composeBarDidClear {
    /** Clear data triggred - you should cleat location and item data */
}

然后实现可选的 RComposeBarDataSource

- (NSInteger) numberOfItemsInComposeBar {
    /** Number of items in item container */
}

- (UIImage *) imageForComposeBarItemAtIndex:(NSInteger)index {
    /** Image item at index at item container
    @return thumbnail image for item (image/video etc) must not be nil */
}

- (NSString *) locationInComposeBar {
    /** Location string to display on compose bar */
    // location will be hidden when not set or returns nil
}

请参阅示例项目以获得更多信息

自定义

大多数可见的 UI 设置都可以自定义以满足您的需求,并且与您的应用主题颜色相匹配。请参阅 RComposeBar.h 文件的在线文档

例如,一些示例自定义属性

_composeBar.topLineColor = [UIColor lightGrayColor];
_composeBar.bottomLineColor = [UIColor lightGrayColor];
_composeBar.textBoxBorderColor = [UIColor redColor];
_composeBar.font =  = [UIFont systemFontOfSize:20];

屏幕截图

alt tag

alt tag

alt tag

GitHub

https://github.com/rjeprasad/RComposeBar

作者

Rajeev Prasad, [email protected]

许可证

RComposeBar 在 MIT 许可证下可用。

版权所有 © 2016 Rajeev Prasad。

特此授予任何人,未经收费,获得本软件及其相关文档文件(以下简称“软件”)的副本的权利,在不受限制的情况下使用软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可以及/或出售软件副本的权利,并允许向软件提供副本的人这样做,但需遵守以下条件:

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

软件按“原样”提供,不提供任何形式的保证,无论是明示的、推定的,包括但不限于适销性、适用于特定用途和侵权保证。在任何情况下,作者或版权所有者都不承担任何索赔、损害或其他责任,无论是在合同行为、侵权或其他行为,源于、出自或与软件或软件的使用或其他处理方式有关。