蜂窝云手机ios
2014-08-07 09:05:59 maomaoxiansheng 阅读数 290
 把这个属性设置成NO,或者删除掉(默认是NO)  [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
2016-10-28 17:56:55 qcx321 阅读数 5050

调用CoreTelephony.framework的私有函数“CTGetSignalStrength”能够获取信号,如下:

int getSignalStrength()
{
void *libHandle = dlopen("/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony", RTLD_LAZY);
int (*CTGetSignalStrength)();
CTGetSignalStrength = dlsym(libHandle, "CTGetSignalStrength");
if( CTGetSignalStrength == NULL) NSLog(@"Could not find CTGetSignalStrength"); 
int result = CTGetSignalStrength();
dlclose(libHandle);
return result;
}
iOS 云
2014-11-07 14:17:56 qq_15420361 阅读数 276
关于这个文档
重点:这是一个初步的文档,尽管它已经审查了技术的准确性,但这不是终点.苹果正在补充这类信息,来帮助你接受技术和编程的接口,描述如下。这些信息是容易改变的,软件的实施根据这篇文档,应该作为最终的审核文档。关于这篇文档 更新信息,去苹果开发者网站,在相关的参考库里面,在文档的输入框里面输入文档的标题,然后呈现。

这个文档让你开始创建一个云工具app 用来存储结构的app和用户的数据在云里。使用云工具代替你的app被不同的用户在不同的设备里面加载—可以用来记录存储在苹果的数据库。如果你有一个模型对象,你想在运行着的不同设备和不同的app之间保持和分享,就是用云工具。这些模型对象被作为记录存储在数据库。用来提供给你和被用户授权

你将会学习怎样
能够使用云工具在你的xcode项目中,创建一个图解的编程方式,或者一个云工具仪表盘
获取记录,订阅你代码中的变化
使用属性类来优化大数据文件和位置数据
订阅记录记录的变化来提高性能
在更新它到app store和mac app store之前在不同的设备上测试你的云工具
配置模式到产品,保持当前你app的每个版本

另请参阅

下面的是WWDC会议提供的更多的关于云工具的风格和结构的细节
1.WWDC 2014:Introducing CloudKit 介绍基本的风格和接口的使用,存储和抓取记录
2.WWDC 2014:Advanced CloudKit 包含的主题有私有化数据,自定义记录空间,确保数据的完整性,有效的建模你的数据。
接下来的文档提供了更多的信息关于相关的主题:
1.Designing for CloudKit in iCloud Design Guide 提供了一个云工具的概述
2.APP Distribution Quick Strat 教你如何规定你的app开发和在你的设备上运行iosApp
3App Distribution Guide 所有的配置步骤,包括配置app 服务和提交你的app到app store 或者mac app store
4.Start Developing IOS Apps Today 或者开始开发Mac Apps 今天介绍xcode和创建基础app的步骤 

翻译地址:https://developer.apple.com/library/ios/documentation/Miscellaneous/Conceptual/CloudKitQuickStart/Introduction/Introduction.html#//apple_ref/doc/uid/TP40014987
2014-09-02 20:08:57 lotusiki 阅读数 4844

网上的UICollectionView的Layout布局,其cell的形状多为矩形和圆形。

本篇博文将正六边形作为cell的基本形状,为您展现独特的蜂窝布局效果及实现源码。

帮助您让自己的App脱颖而出,更加与众不同。


最新完整代码下载地址:https://github.com/duzixi/Varied-Layouts

博文首发地址:http://blog.csdn.net/duzixi


实现效果图:



核心源代码:


自定义Layout

//
//  HoneyCombLayout.h
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import <UIKit/UIKit.h>

@interface HoneyCombLayout : UICollectionViewLayout

@property (nonatomic, assign) NSInteger margin;
@property (nonatomic, assign) NSInteger oX;
@property (nonatomic, assign) NSInteger oY;

@end

//
//  HoneyCombLayout.m
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import "HoneyCombLayout.h"

@implementation HoneyCombLayout

///  返回内容大小,用于判断是否需要加快滑动

-(CGSize)collectionViewContentSize
{
    float height = (SIZE + self.margin) * ([self.collectionView numberOfItemsInSection:0] / 4 + 1);
    return CGSizeMake(320, height);
}


///  返回YES,改变布局
/*
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
{
    return YES;
}
*/
#pragma mark - UICollectionViewLayout
///  为每一个Item生成布局特性
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
    
    UICollectionView *collection = self.collectionView;

    float x = (SIZE + self.margin) * (indexPath.item % COL + 1) * 0.75;
    float y = (SIZE + self.margin) * (indexPath.item / COL + 0.5) * cos(M_PI * 30.0f / 180.0f);
    if (indexPath.item % 2 == 1) {
        y += (SIZE + self.margin) * 0.5 * cosf(M_PI * 30.0f / 180.0f);
    }
    
    x += self.oX;
    y += self.oY;
    
    attributes.center = CGPointMake(x + collection.contentOffset.x, y + collection.contentOffset.y);
    attributes.size = CGSizeMake(SIZE, SIZE * cos(M_PI * 30.0f / 180.0f));
    
    return attributes;
}

-(NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
    NSArray *arr = [super layoutAttributesForElementsInRect:rect];
    if ([arr count] > 0) {
        return arr;
    }
    NSMutableArray *attributes = [NSMutableArray array];
    for (NSInteger i = 0 ; i < [self.collectionView numberOfItemsInSection:0 ]; i++) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
        [attributes addObject:[self layoutAttributesForItemAtIndexPath:indexPath]];
    }
    return attributes;
}



@end

自定义cell:

//
//  HoneycombViewCell.h
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import <UIKit/UIKit.h>

@interface HoneycombViewCell : UICollectionViewCell

@property (nonatomic,strong) UILabel *titleLabel;

@end

//
//  HoneycombViewCell.m
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import "HoneycombViewCell.h"

@implementation HoneycombViewCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.titleLabel];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    // step 1: 生成六边形路径
    CGFloat longSide = SIZE * 0.5 * cosf(M_PI * 30 / 180);
    CGFloat shortSide = SIZE * 0.5 * sin(M_PI * 30 / 180);
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(0, longSide)];
    [path addLineToPoint:CGPointMake(shortSide, 0)];
    [path addLineToPoint:CGPointMake(shortSide + SIZE * 0.5, 0)];
    [path addLineToPoint:CGPointMake(SIZE, longSide)];
    [path addLineToPoint:CGPointMake(shortSide + SIZE * 0.5, longSide * 2)];
    [path addLineToPoint:CGPointMake(shortSide, longSide * 2)];
    [path closePath];
    
    // step 2: 根据路径生成蒙板
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.path = [path CGPath];
    
    // step 3: 给cell添加模版
    self.layer.mask = maskLayer;

    
    self.backgroundColor = [UIColor orangeColor];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.frame = self.contentView.frame;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end


2017-05-28 09:51:00 weixin_33943347 阅读数 8

网上的UICollectionView的Layout布局,其cell的形状多为矩形和圆形。

本篇博文将正六边形作为cell的基本形状,为您展现独特的蜂窝布局效果及实现源代码。

帮助您让自己的App脱颖而出,更加与众不同。


最新完整代码下载地址:https://github.com/duzixi/Varied-Layouts

博文首发地址:http://blog.csdn.net/duzixi


实现效果图:



核心源码:


自己定义Layout

//
//  HoneyCombLayout.h
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import <UIKit/UIKit.h>

@interface HoneyCombLayout : UICollectionViewLayout

@property (nonatomic, assign) NSInteger margin;
@property (nonatomic, assign) NSInteger oX;
@property (nonatomic, assign) NSInteger oY;

@end

//
//  HoneyCombLayout.m
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import "HoneyCombLayout.h"

@implementation HoneyCombLayout

///  返回内容大小。用于推断是否须要加快滑动

-(CGSize)collectionViewContentSize
{
    float height = (SIZE + self.margin) * ([self.collectionView numberOfItemsInSection:0] / 4 + 1);
    return CGSizeMake(320, height);
}


///  返回YES,改变布局
/*
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
{
    return YES;
}
*/
#pragma mark - UICollectionViewLayout
///  为每个Item生成布局特性
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
    
    UICollectionView *collection = self.collectionView;

    float x = (SIZE + self.margin) * (indexPath.item % COL + 1) * 0.75;
    float y = (SIZE + self.margin) * (indexPath.item / COL + 0.5) * cos(M_PI * 30.0f / 180.0f);
    if (indexPath.item % 2 == 1) {
        y += (SIZE + self.margin) * 0.5 * cosf(M_PI * 30.0f / 180.0f);
    }
    
    x += self.oX;
    y += self.oY;
    
    attributes.center = CGPointMake(x + collection.contentOffset.x, y + collection.contentOffset.y);
    attributes.size = CGSizeMake(SIZE, SIZE * cos(M_PI * 30.0f / 180.0f));
    
    return attributes;
}

-(NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
    NSArray *arr = [super layoutAttributesForElementsInRect:rect];
    if ([arr count] > 0) {
        return arr;
    }
    NSMutableArray *attributes = [NSMutableArray array];
    for (NSInteger i = 0 ; i < [self.collectionView numberOfItemsInSection:0 ]; i++) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
        [attributes addObject:[self layoutAttributesForItemAtIndexPath:indexPath]];
    }
    return attributes;
}



@end

自己定义cell:

//
//  HoneycombViewCell.h
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import <UIKit/UIKit.h>

@interface HoneycombViewCell : UICollectionViewCell

@property (nonatomic,strong) UILabel *titleLabel;

@end

//
//  HoneycombViewCell.m
//  Demo-Layouts
//
//  Created by 杜子兮(duzixi) on 14-9-1.
//  Copyright (c) 2014年 lanou3g.com All rights reserved.
//

#import "HoneycombViewCell.h"

@implementation HoneycombViewCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.titleLabel];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    // step 1: 生成六边形路径
    CGFloat longSide = SIZE * 0.5 * cosf(M_PI * 30 / 180);
    CGFloat shortSide = SIZE * 0.5 * sin(M_PI * 30 / 180);
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(0, longSide)];
    [path addLineToPoint:CGPointMake(shortSide, 0)];
    [path addLineToPoint:CGPointMake(shortSide + SIZE * 0.5, 0)];
    [path addLineToPoint:CGPointMake(SIZE, longSide)];
    [path addLineToPoint:CGPointMake(shortSide + SIZE * 0.5, longSide * 2)];
    [path addLineToPoint:CGPointMake(shortSide, longSide * 2)];
    [path closePath];
    
    // step 2: 依据路径生成蒙板
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.path = [path CGPath];
    
    // step 3: 给cell加入模版
    self.layer.mask = maskLayer;

    
    self.backgroundColor = [UIColor orangeColor];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.frame = self.contentView.frame;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end


IOS手机截屏

阅读数 1

没有更多推荐了,返回首页