UIWebView加载CSS样式的html

时间:2024-12-12 11:04:32

UIWebView加载CSS样式的html

UIWebView加载CSS样式的html

效果

UIWebView加载CSS样式的html

源码

//
// ViewController.m
// CSS
//
// Created by YouXianMing on 16/7/19.
// Copyright © 2016年 YouXianMing. All rights reserved.
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor];
CGFloat width = self.view.bounds.size.width;
CGFloat height = self.view.bounds.size.height; NSString *cssContentString = [NSString stringWithFormat:
@"<html> \n" "<head> \n"
"<style type=\"text/css\"> \n"
"h1 {font-size: 20; font-family: \"Heiti SC\"; color: 4C4741;}\n"
"body {font-size: 15; font-family: \"Heiti SC\"; color: 4C4741;}\n"
"p.style1 {text-indent: 2em;} \n"
"p.style2 {text-indent: 2em; color: 000000;} \n"
"</style> \n"
"</head> \n" "<body>"
"<h1 align=\"center\">穷玩车,富玩表,SB玩电脑