iToast copy .to be explained lat

2016-11-02  本文已影响43人  LV大树

/*

iToast.h

MIT LICENSE

Copyright (c) 2012 Guru Software

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Copyright (c) 2014年 timliu: 9925124@qq.com . All rights reserved.
*/

import <Foundation/Foundation.h>

import <UIKit/UIKit.h>

typedef enum iToastGravity {
iToastGravityTop = 1000001,
iToastGravityBottom,
iToastGravityCenter
}iToastGravity;

enum iToastDuration {
iToastDurationLong = 10000,
iToastDurationShort = 1000,
iToastDurationNormal = 3000
}iToastDuration;

typedef enum iToastType {
iToastTypeInfo = -100000,
iToastTypeNotice,
iToastTypeWarning,
iToastTypeError,
iToastTypeNone // For internal use only (to force no image)
}iToastType;

typedef enum {
iToastImageLocationTop,
iToastImageLocationLeft
} iToastImageLocation;

@class iToastSettings;

@interface iToast : NSObject {
iToastSettings *_settings;

NSTimer *timer;

UIView *view;
NSString *text;

}

// 添加初始化方法:

-(iToastSettings *) theSettings;

@end

@interface iToastSettings : NSObject<NSCopying>{

}

@property(assign) NSInteger duration;
@property(assign) iToastGravity gravity;
@property(assign) CGPoint postition;
@property(assign) CGFloat fontSize;
@property(nonatomic, strong) UIColor *fontColor; // 字体颜色
@property(assign) BOOL useShadow;
@property(assign) CGFloat cornerRadius;
@property(assign) CGFloat bgRed;
@property(assign) CGFloat bgGreen;
@property(assign) CGFloat bgBlue;
@property(assign) CGFloat bgAlpha;
@property(assign) NSInteger offsetLeft;
@property(assign) NSInteger offsetTop;
@property(readonly) NSDictionary *images;
@property(assign) iToastImageLocation imageLocation;

@end

//h up
/*********************************************/
//m donw

/*

iToast.m

MIT LICENSE

Copyright (c) 2011 Guru Software

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Copyright (c) 2014年 timliu: 9925124@qq.com . All rights reserved.
*/

import "iToast.h"

import <QuartzCore/QuartzCore.h>

define CURRENT_TOAST_TAG 6984678

define IOS7_OR_LATER ( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )

static const CGFloat kComponentPadding = 5;

static iToastSettings *sharedSettings = nil;

@interface iToast(private){

}

@end

@implementation iToast

// view = [v retain];
// view = [v retain];
// __strong view = v;
view = v;

[v addTarget:self action:@selector(hideToast:) forControlEvents:UIControlEventTouchDown];

}

}

// 设置字体颜色:默认是白色

-(iToastSettings *) theSettings{
if (!_settings) {
_settings = [[iToastSettings getSharedSettings] copy];
}

return _settings;

}

@end

@implementation iToastSettings

}

@end

上一篇 下一篇

猜你喜欢

热点阅读