131 lines
4.4 KiB
Objective-C
Executable File

//
// FirstViewController.m
// Talk
//
// Created by xuzs on 22/10/11.
// Copyright (c) 2022年 xuzs. All rights reserved.
//
#import "Web.h"
#import "UI.h"
#import "HttpManager.h"
#import "Msg.h"
#import "Pub.h"
#import "sysInfo.h"
#import "EquList.h"
#import "HttpManager.h"
@interface Web ()
@property (nonatomic, strong)UIView *rview;
@property (nonatomic, strong)UIScrollView *scrollView;
@property (nonatomic, strong)UILabel *webLabel;
@end
@implementation Web
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:55/255. green:143/255. blue:232/255. alpha:1];//#378fe8
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self setNavTitle:@"用户隐私协议"];
[self setNavLeft:@"back" action:@selector(pageBack2)];
[self setupViews];
[self setUI];
[HttpManager loadPage:@"http://47.107.109.110/app/privacy1.aspx" HttpResultHandler:^(NSData * data) {//
//NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//ret = [ret stringByAppendingFormat:@"<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>"];
NSDictionary *options = @{ NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute :@(NSUTF8StringEncoding) };
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
NSMutableParagraphStyle *para = [[NSMutableParagraphStyle alloc] init];
para.lineSpacing = 7;
para.paragraphSpacing = 10;
[attStr addAttribute:NSParagraphStyleAttributeName value:para range:NSMakeRange(0, attStr.length)];
self.webLabel.attributedText = attStr;
//NSLog(@"%@",self.webLabel.attributedText);
CGRect desRect = [attStr boundingRectWithSize:CGSizeMake([UI getScreenWidth]-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil];
self.scrollView.contentSize=CGSizeMake( [UI getScreenWidth],desRect.size.height + 100);
self.webLabel.frame = CGRectMake(10,0,[UI getScreenWidth]-20, desRect.size.height + 40);
}];
}
- (void)pageBack2{
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)setupViews
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
[self.view addSubview:self.rview];
[self.rview addSubview:self.scrollView];
[self.scrollView addSubview:self.webLabel];
}
- (void)setUI{
[UI SetRView:self.rview Top:@"0" Right:@"0" Bottom:@"0" Left:@"0"];
//self.scrollView.contentSize=CGSizeMake( [UI getScreenWidth],4000);
//self.webLabel.frame = CGRectMake(0,0,[UI getScreenWidth], 4000);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark Property Accessors
- (UIView *)rview
{
if (!_rview) {
_rview = [[UIView alloc] init];
_rview.backgroundColor = [UIColor colorWithRed:241/255. green:241/255. blue:241/255. alpha:1];
}
return _rview;
}
- (UIScrollView *)scrollView{
if(!_scrollView){
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [UI getScreenWidth], [UI getScreenHeight])];
_scrollView.pagingEnabled = NO;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = YES;
_scrollView.delegate = self;
}
return _scrollView;
}
- (UILabel *)webLabel
{
if (!_webLabel) {
_webLabel = [[UILabel alloc] init];
//_webView.backgroundColor = [UIColor colorWithRed:241/255. green:241/255. blue:241/255. alpha:1];
_webLabel.font = [UIFont systemFontOfSize:13.0f];
_webLabel.textColor = [UIColor blackColor];
_webLabel.textAlignment = NSTextAlignmentLeft;
_webLabel.text = NSLocalizedString(@"", nil);
_webLabel.numberOfLines = 0;
}
return _webLabel;
}
@end