IOS 跑马灯效果
来源:互联网 发布:文件服务器同步软件 编辑:程序博客网 时间:2024/04/29 13:27
//
// UIAdvertisingView.m
// test2
//
// Created by liangliang on 11-7-29.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#import"UIAdvertisingView.h"
@implementation UIAdvertisingView
@synthesize myArray;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
//初始化代码
[selfsetBackgroundColor:[UIColorclearColor]];
if (myAdView==nil) {
myAdView=[[UIViewalloc] initWithFrame: frame];//CGRectMake(0, 0, 188, 33)];
[myAdViewsetClipsToBounds:YES];
if (myLable==nil) {
myLable=[[UILabel alloc] initWithFrame: frame]; //CGRectMake(0, 40, 300, 200)];
[myLablesetFont:[UIFontfontWithName:@"Helvetica"size:12.0]];
[myLablesetNumberOfLines:0];
[myLablesetBackgroundColor:[UIColorclearColor]];
[myAdViewaddSubview:myLable];
}
[myAdViewsetBackgroundColor:[UIColorclearColor]];
[selfaddSubview:myAdView];
}
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
- (void)dealloc
{
[[NSNotificationCenterdefaultCenter] removeObserver:self];
if (timer!=nil&&[timerisValid]) {
[timerinvalidate];
timer=nil;
}
self.myArray=nil;
[self.myArrayrelease];
myAdView=nil;
[myAdViewrelease];
myLable=nil;
[myLablerelease];
[superdealloc];
}
-(void)addAdvertisingList
{
//数据层
self.myArray=[[NSMutableArrayalloc] initWithCapacity:1];
[self.myArrayaddObject:@"大家好"];
[self.myArrayaddObject:@"We are pleased to announce that the fourth milestone release of the Spring Android project is now available!"];
if ([self.myArraycount]) {
[myLablesetText:@""];
NSString *text=nil;
for ( int i=0; i<[self.myArraycount]; i++) {
if (i==0) {
text=[self.myArrayobjectAtIndex:i];
}else{
text=[NSStringstringWithFormat:@"%@\n%@",text,[self.myArrayobjectAtIndex:i]];
}
}
UIFont *font = [UIFont fontWithName:@"Helvetica" size:10.0];
CGSize size = [textsizeWithFont:font constrainedToSize:CGSizeMake(175.0f,2000.0f) lineBreakMode:UILineBreakModeWordWrap];
CGRect rect=myLable.frame;
rect.size=size;
[myLablesetFrame:rect];
[myLablesetText:text];
if (timer==nil) {
timer=[NSTimerscheduledTimerWithTimeInterval: 0.05
target: self
selector: @selector(handleTimer:)
userInfo: nil
repeats: YES];
}
}
}
-(void)handleTimer:(id)sender
{
if ([self.myArraycount]>0) {
CGRect newFrame1 = myLable.frame;
if (newFrame1.origin.y<-newFrame1.size.height) {
newFrame1.origin.y =23;
[myLablesetFrame:newFrame1];
}else {
newFrame1.origin.y = newFrame1.origin.y-0.8;
[myLablesetFrame:newFrame1];
}
}
}
@end
//
// UIAdvertisingView.h
// test2
//
// Created by liangliang on 11-7-29.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#import<UIKit/UIKit.h>
@interface UIAdvertisingView :UIView {
NSMutableArray *myArray;
UIView * myAdView;
UILabel * myLable;
NSTimer *timer;
}
-(void)addAdvertisingList;
-(void)handleTimer:(id)sender;
@property (nonatomic,retain) NSMutableArray *myArray;
@end
- IOS 跑马灯效果
- iOS 跑马灯效果
- iOS 跑马灯效果
- IOS跑马灯效果
- iOS实现跑马灯效果
- iOS实现跑马灯效果
- iOS 跑马灯效果展示
- iOS跑马灯效果的源代码
- iOS 实现UILabel的跑马灯效果
- iOS 局部跑马灯效果实现
- flex 跑马灯效果
- Android 跑马灯效果
- 跑马灯效果
- android跑马灯效果
- android跑马灯效果
- 跑马灯效果
- 文字跑马灯效果
- 跑马灯效果
- 为什么要让我们的“领域模型”裸奔?
- hibernate持久化对象状态
- adb运行顺序
- ASP.NET代码分离
- 将administrator用户出现在登录界面里
- IOS 跑马灯效果
- IOS开发技巧之──字数统计函数
- 取其精华
- plsql Developer 登录oracle出现 initialization error
- ASP.NET应用技巧:非托管COM组件的使用
- tomcat6.0 下的log4j日志文件 配置过程
- DLL中调用约定和名称修饰
- Flash桌球游戏开发
- 区分Activity的四种加载模式