MEVHorizontalContacts 1.4

MEVHorizontalContacts 1.4

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

Manuel Escrig 维护。




M امکان مشاهده لیست تماس‌ها به صورت قابل تنظیم به کمک عناصر قابل گسترش.

眺望

  • [x] سلول‌های تماس قابل شخصی‌سازی
  • [x] سلول‌های عناصر تماس قابل شخصی‌سازی
  • [x] اندازه‌های مختلف و طراحی پاسخگو
  • [x] روش‌های دلیگیت چندگانه

نمونه برنامه

برنامه نمونه را اجرا کنید و با آن بازی کنید! نمونه برنامه

پروژه نمونه

برای اجرای پروژه نمونه، مخزن را کپی کنید و ابتدا از پوشه Example pod install را运行 کنید.

شروع به کار

نیازها

نیاز به iOS SDK نسخه > 7.0 دارد

نیاز به ARC دارد

Podfile

برای تعامل MEVHorizontalContacts با پروژه Xcode خود از CocoaPods استفاده کنید، آن را در Podfile خود مشخص کنید

source 'https://github.com/CocoaPods/Specs.git'
pod 'MEVHorizontalContacts'

سپس، دستور زیر را اجرا کنید

$ pod install

نصب دستی

برای تعامل MEVHorizontalContacts با پروژه Xcode خود به صورت دستی،فایل‌های موجود در پوشه /Pod/Classes/ را به پروژه App خود اضافه کنید.

سپس، فایل زیر را در کلاس‌های خود وارد کنید

#import "MEVHorizontalContacts.h"

راهنمای سریع

استفاده

1. وارد کردن کلاس
#import "MEVHorizontalContacts.h"
2. اضافه کردن پروتکل‌های Datasource و Delegate.
@interface ViewController () <MEVHorizontalContactsDataSource, MEVHorizontalContactsDelegate>
@property (nonatomic, strong) MEVHorizontalContacts *horizontalContacts;
@end
3. ایجاد، تنظیم اولیه و افزودن ویژگی MEVHorizontalContacts.
_horizontalContacts = [MEVHorizontalContacts new];
_horizontalContacts.backgroundColor = [UIColor whiteColor];
_horizontalContacts.dataSource = self;
_horizontalContacts.delegate = self;
[self addSubview:_horizontalContacts];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[horizontalContacts]|" options:NSLayoutFormatAlignAllCenterX metrics:nil views:@{@"horizontalContacts" : _horizontalContacts}]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[horizontalContacts]|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:@{@"horizontalContacts" : _horizontalContacts}]];
4. اجرای روش‌های Datasource
#pragma mark - MEVHorizontalContactsDataSource Methods

- (NSInteger)numberOfContacts;
- (NSInteger)numberOfItemsAtContactIndex:(NSInteger)index;
- (MEVHorizontalContactsCell *)contactAtIndex:(NSInteger)index;
- (MEVHorizontalContactsCell *)item:(NSInteger)item atContactIndex:(NSInteger)index;
- (UIEdgeInsets)horizontalContactsInsets;
- (NSInteger)horizontalContactsSpacing;
5. اجرای روش‌های Delegate
#pragma mark - MEVHorizontalContactsDelegate Methods

- (void)contactSelectedAtIndex:(NSInteger)index;
- (void)item:(NSInteger)item selectedAtContactIndex:(NSInteger)index;

示例

自定义 1

- (MEVHorizontalContactsCell *)contactAtIndex:(NSInteger)index {
    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableContactCellForIndex:index];
    [cell.imageView setImage:[UIImage imageNamed:[self getImageNameAtIndex:index]]];
    [cell.imageView.layer setBorderColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1].CGColor];
    [cell.imageView.layer setBorderWidth:1.0f];
    [cell.label setText:[self getUserNameAtIndex:index]];
    [cell.label setFont:[UIFont boldSystemFontOfSize:12.0f]];
    return cell;
}

- (MEVHorizontalContactsCell *)item:(NSInteger)item atContactIndex:(NSInteger)index {

    UIImage *image;
    NSString *labelText;
    switch (item) {
        case 0:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
        case 1:
            labelText = @"Email";
            image = [UIImage imageNamed:@"actionEmail"];
            break;
        case 2:
            labelText = @"Message";
            image = [UIImage imageNamed:@"actionMessage"];
            break;
        default:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
    }

    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableItemCellForIndex:index];
    [cell.imageView setImage:image];
    [cell.imageView setTintColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1]];
    [cell.imageView.layer setBorderColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1].CGColor];
    [cell.imageView.layer setBorderWidth:1.0f];
    [cell.label setText:labelText];
    [cell.label setFont:[UIFont boldSystemFontOfSize:10.0f]];

    return cell;
}
自定义 2

- (MEVHorizontalContactsCell *)contactAtIndex:(NSInteger)index {
    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableContactCellForIndex:index];
    [cell.imageView setImage:[UIImage imageNamed:[self getImageNameAtIndex:index]]];
    [cell.label setText:[self getUserNameAtIndex:index]];
    return cell;
}

- (MEVHorizontalContactsCell *)item:(NSInteger)item atContactIndex:(NSInteger)index {

    UIImage *image;
    NSString *labelText;
    switch (item) {
        case 0:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
        case 1:
            labelText = @"Email";
            image = [UIImage imageNamed:@"actionEmail"];
            break;
        case 2:
            labelText = @"Message";
            image = [UIImage imageNamed:@"actionMessage"];
            break;
        default:
            labelText = @"Call";
            image = [UIImage imageNamed:@"actionCall"];
            break;
    }

    MEVHorizontalContactsCell *cell = [_horizontalContacts dequeueReusableItemCellForIndex:index];
    [cell.imageView setImage:image];
    [cell.imageView setBackgroundColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1]];
    [cell.imageView setTintColor:[UIColor whiteColor]];
    [cell.label setText:labelText];
    [cell.label setTextColor:[UIColor colorWithRed:34/255.0f green:167/255.0f blue:240/255.0f alpha:1]];
    return cell;
}

路线图

  • [x] 支持 CocoaPods
  • [ ] 支持 Carthage
  • [ ] 测试

变更日志

查看 变更日志.md

作者

使用此库的应用

许可证

MEVHorizontalContacts 在 MIT 许可证下可用。更多信息请参阅 LICENSE 文件。

图标由 Gregor Cresnar 制作,并通过 Creative Commons BY 3.0 许可。