UIScrollView图文混排仿网易新闻

公司求做作一个有图有文的简介说明,第一时间想到用UIWebview,但想到只有一篇而儿,用UIWebview确实是大才小用了,,


1、H文件


#import <UIKit/UIKit.h>


@interface ddd : UIViewController<UIScrollViewDelegate>{

    UIScrollView *scrollView;

}

@property (nonatomic,retain) UIScrollView *scrollView;



@end




2、M文件

#import "ddd.h"

#import "RTLabel.h"


@interface ddd ()


@end


@implementation ddd

@synthesize scrollView;



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


- (void)viewDidLoad

{

    scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];//这里的CGRectMake(0, 0, 320, 460)的意思是,从(0,0)这个点-也就是左上角开始生成一个宽为320、长为460大小一个UIScrollView

    scrollView.backgroundColor = [UIColor grayColor];

    scrollView.delegate = self;

    scrollView.clipsToBounds = YES;

    scrollView.canCancelContentTouches = YES;

    scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;    

   // 设置内容大小

    scrollView.contentSize = CGSizeMake(320, 840);

   // 是否分页

    scrollView.pagingEnabled = NO;//这里很重要,因为设置为YES会出现滑动不流畅

     // 提示用户,Indicators flash

    [scrollView flashScrollIndicators];

    // 是否同时运动,lock

    scrollView.directionalLockEnabled = YES;

    scrollView.bouncesZoom = NO;    

    [self.view addSubview:scrollView];    

    

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"3V8A0209_1.jpg"]];

    [imageView setFrame:CGRectMake(100, 10, 100, 100)];

    [scrollView addSubview:imageView];

    [scrollView setScrollEnabled:YES];


         

RTLabel *aboutRT = [[RTLabel alloc] initWithFrame:CGRectMake(8, 110, 310, 300)];

    aboutRT.text@"<p indent=30 ><font   size=16 color='#ffffff'>肇庆市东海影视文化发展有限公司(以下简称东海影视)是经国家广电总局批准的、有拍摄许可证的肇庆首间影视公司。公司主营业务为影视剧摄制发行(含影视广告及栏目制作)、动漫制作、《西江月·行游肇庆》旅游文化杂志和旅游文化活动策划这四大块。</font></p>";

   // websiteRT.delegate = self;

    [self.scrollView addSubview:aboutRT];

    [aboutRT release];

    

    RTLabel *aboutRT1 = [[RTLabel alloc] initWithFrame:CGRectMake(8, 290, 310, 300)];

    aboutRT1.text@"<p indent=30 ><font   size=16 color='#ffffff'>在业务发展过程中,东海影视不断完善人才结构和人才形成了文化专家组、影视剧摄制团队(含导演、签约演员、编剧、美术指导、摄像师、灯光师等)、杂志编辑团队(采编、摄影、平面设计等)、活动策划执行团队[与中华文化促进会(直属国家文化部)等高端团队建立了长期的项目策划合作关系]等专业团队。</font></p>";

    // websiteRT.delegate = self;

    [self.scrollView addSubview:aboutRT1];

    [aboutRT1 release];

    

    RTLabel *aboutRT2 = [[RTLabel alloc] initWithFrame:CGRectMake(8, 520, 310, 300)];

    aboutRT2.text@"<p indent=30 ><font   size=16 color='#ffffff'>东海影视以推动肇庆市影视文化产业的发展为目标,围绕着肇庆市人民政府提出的打造国际知名旅游会展胜地的城市总体发展定位,侧重于岭南古郡、山水名城旅游城市发展思路,以影视为表、旅游为里、文化为魂作为经营理念,依托肇庆千里旅游画廊的真山、真水、真景和中国砚都文化长廊的深厚内涵,用悠游肇庆,慢漫的享受的感觉定位从影视作品、旅游杂志、动漫作品、活动策划及栏目制作等角度解读肇庆的旅游和文化,致力于向全省、全国乃至全世界推动肇庆的旅游文化产业。</font></p>";

    // websiteRT.delegate = self;

    [self.scrollView addSubview:aboutRT2];

    [aboutRT2 release];


注:文字我使用RTLabel,使用时请系头部加上#import "RTLabel.h",至于RTLable可自行上网搜索下载。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值