Skip to content

Commit dd8fb6a

Browse files
author
Darcy Liu
committed
add TransWeb
1 parent 8c4e04f commit dd8fb6a

22 files changed

+1407
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,4 +1336,20 @@ This sample demonstrates how to use a texture atlas to draw multiple objects wit
13361336

13371337
[URL](https://developer.apple.com/library/ios/#samplecode/GLTextureAtlas/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009014)
13381338

1339-
Last Revision: Version 1.5, 2010-06-25
1339+
Last Revision: Version 1.5, 2010-06-25
1340+
1341+
#TransWeb#
1342+
1343+
Demonstrates how to implement UIWebView with a transparent background.
1344+
1345+
To achieve this you need to make the HTML body's background color transparent by doing the following -
1346+
1347+
1) set the UIWebView's backgroundColor property to [UIColor clearColor]
1348+
1349+
2) use the UIWebView's content in the html: <body style="background-color: transparent">
1350+
1351+
3) the UIWebView's opaque property set to NO
1352+
1353+
[URL](https://developer.apple.com/library/ios/#samplecode/TransWeb/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008614)
1354+
1355+
Last Revision: Version 1.4, 2010-06-25

TransWeb.zip

555 KB
Binary file not shown.

TransWeb/AppDelegate.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
File: AppDelegate.h
3+
Abstract: The application delegate class used for installing our navigation controller.
4+
Version: 1.4
5+
6+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7+
Inc. ("Apple") in consideration of your agreement to the following
8+
terms, and your use, installation, modification or redistribution of
9+
this Apple software constitutes acceptance of these terms. If you do
10+
not agree with these terms, please do not use, install, modify or
11+
redistribute this Apple software.
12+
13+
In consideration of your agreement to abide by the following terms, and
14+
subject to these terms, Apple grants you a personal, non-exclusive
15+
license, under Apple's copyrights in this original Apple software (the
16+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
17+
Software, with or without modifications, in source and/or binary forms;
18+
provided that if you redistribute the Apple Software in its entirety and
19+
without modifications, you must retain this notice and the following
20+
text and disclaimers in all such redistributions of the Apple Software.
21+
Neither the name, trademarks, service marks or logos of Apple Inc. may
22+
be used to endorse or promote products derived from the Apple Software
23+
without specific prior written permission from Apple. Except as
24+
expressly stated in this notice, no other rights or licenses, express or
25+
implied, are granted by Apple herein, including but not limited to any
26+
patent rights that may be infringed by your derivative works or by other
27+
works in which the Apple Software may be incorporated.
28+
29+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34+
35+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42+
POSSIBILITY OF SUCH DAMAGE.
43+
44+
Copyright (C) 2010 Apple Inc. All Rights Reserved.
45+
46+
*/
47+
48+
#import <UIKit/UIKit.h>
49+
50+
@interface AppDelegate : NSObject <UIApplicationDelegate>
51+
{
52+
UIWindow *window;
53+
UINavigationController *myNavController;
54+
}
55+
56+
@property (nonatomic, retain) IBOutlet UIWindow *window;
57+
@property (nonatomic, retain) IBOutlet UINavigationController *myNavController;
58+
59+
@end

TransWeb/AppDelegate.m

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
File: AppDelegate.m
3+
Abstract: The application delegate class used for installing our navigation controller.
4+
Version: 1.4
5+
6+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7+
Inc. ("Apple") in consideration of your agreement to the following
8+
terms, and your use, installation, modification or redistribution of
9+
this Apple software constitutes acceptance of these terms. If you do
10+
not agree with these terms, please do not use, install, modify or
11+
redistribute this Apple software.
12+
13+
In consideration of your agreement to abide by the following terms, and
14+
subject to these terms, Apple grants you a personal, non-exclusive
15+
license, under Apple's copyrights in this original Apple software (the
16+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
17+
Software, with or without modifications, in source and/or binary forms;
18+
provided that if you redistribute the Apple Software in its entirety and
19+
without modifications, you must retain this notice and the following
20+
text and disclaimers in all such redistributions of the Apple Software.
21+
Neither the name, trademarks, service marks or logos of Apple Inc. may
22+
be used to endorse or promote products derived from the Apple Software
23+
without specific prior written permission from Apple. Except as
24+
expressly stated in this notice, no other rights or licenses, express or
25+
implied, are granted by Apple herein, including but not limited to any
26+
patent rights that may be infringed by your derivative works or by other
27+
works in which the Apple Software may be incorporated.
28+
29+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34+
35+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42+
POSSIBILITY OF SUCH DAMAGE.
43+
44+
Copyright (C) 2010 Apple Inc. All Rights Reserved.
45+
46+
*/
47+
48+
#import "AppDelegate.h"
49+
50+
@implementation AppDelegate;
51+
52+
@synthesize window, myNavController;
53+
54+
- (void)dealloc
55+
{
56+
[myNavController release];
57+
[window release];
58+
59+
[super dealloc];
60+
}
61+
62+
- (void)applicationDidFinishLaunching:(UIApplication *)application
63+
{
64+
// create window and set up table view controller
65+
[window addSubview:myNavController.view];
66+
67+
[window makeKeyAndVisible];
68+
}
69+
70+
@end

TransWeb/Info.plist

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIconFiles</key>
12+
<array>
13+
<string>Icon.png</string>
14+
<string>Icon-72.png</string>
15+
<string>[email protected]</string>
16+
<string>Icon-Small.png</string>
17+
<string>Icon-Small-50.png</string>
18+
<string>[email protected]</string>
19+
</array>
20+
<key>CFBundleIdentifier</key>
21+
<string>com.apple.samplecode.${PRODUCT_NAME:identifier}</string>
22+
<key>CFBundleInfoDictionaryVersion</key>
23+
<string>6.0</string>
24+
<key>CFBundleName</key>
25+
<string>${PRODUCT_NAME}</string>
26+
<key>CFBundlePackageType</key>
27+
<string>APPL</string>
28+
<key>CFBundleSignature</key>
29+
<string>????</string>
30+
<key>CFBundleVersion</key>
31+
<string>1.4</string>
32+
<key>NSMainNibFile</key>
33+
<string>MainWindow</string>
34+
<key>LSRequiresIPhoneOS</key>
35+
<true/>
36+
</dict>
37+
</plist>

TransWeb/MyViewController.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
File: MyViewController.h
3+
Abstract: The main view controller of this app.
4+
Version: 1.4
5+
6+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7+
Inc. ("Apple") in consideration of your agreement to the following
8+
terms, and your use, installation, modification or redistribution of
9+
this Apple software constitutes acceptance of these terms. If you do
10+
not agree with these terms, please do not use, install, modify or
11+
redistribute this Apple software.
12+
13+
In consideration of your agreement to abide by the following terms, and
14+
subject to these terms, Apple grants you a personal, non-exclusive
15+
license, under Apple's copyrights in this original Apple software (the
16+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
17+
Software, with or without modifications, in source and/or binary forms;
18+
provided that if you redistribute the Apple Software in its entirety and
19+
without modifications, you must retain this notice and the following
20+
text and disclaimers in all such redistributions of the Apple Software.
21+
Neither the name, trademarks, service marks or logos of Apple Inc. may
22+
be used to endorse or promote products derived from the Apple Software
23+
without specific prior written permission from Apple. Except as
24+
expressly stated in this notice, no other rights or licenses, express or
25+
implied, are granted by Apple herein, including but not limited to any
26+
patent rights that may be infringed by your derivative works or by other
27+
works in which the Apple Software may be incorporated.
28+
29+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34+
35+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42+
POSSIBILITY OF SUCH DAMAGE.
43+
44+
Copyright (C) 2010 Apple Inc. All Rights Reserved.
45+
46+
*/
47+
48+
#import <UIKit/UIKit.h>
49+
50+
@interface MyViewController : UIViewController
51+
{
52+
UIWebView *webView;
53+
}
54+
55+
@property (nonatomic, retain) IBOutlet UIWebView *webView;
56+
57+
@end

TransWeb/MyViewController.m

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
File: MyViewController.m
3+
Abstract: The main view controller of this app.
4+
Version: 1.4
5+
6+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7+
Inc. ("Apple") in consideration of your agreement to the following
8+
terms, and your use, installation, modification or redistribution of
9+
this Apple software constitutes acceptance of these terms. If you do
10+
not agree with these terms, please do not use, install, modify or
11+
redistribute this Apple software.
12+
13+
In consideration of your agreement to abide by the following terms, and
14+
subject to these terms, Apple grants you a personal, non-exclusive
15+
license, under Apple's copyrights in this original Apple software (the
16+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
17+
Software, with or without modifications, in source and/or binary forms;
18+
provided that if you redistribute the Apple Software in its entirety and
19+
without modifications, you must retain this notice and the following
20+
text and disclaimers in all such redistributions of the Apple Software.
21+
Neither the name, trademarks, service marks or logos of Apple Inc. may
22+
be used to endorse or promote products derived from the Apple Software
23+
without specific prior written permission from Apple. Except as
24+
expressly stated in this notice, no other rights or licenses, express or
25+
implied, are granted by Apple herein, including but not limited to any
26+
patent rights that may be infringed by your derivative works or by other
27+
works in which the Apple Software may be incorporated.
28+
29+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34+
35+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42+
POSSIBILITY OF SUCH DAMAGE.
43+
44+
Copyright (C) 2010 Apple Inc. All Rights Reserved.
45+
46+
*/
47+
48+
#import "MyViewController.h"
49+
50+
@implementation MyViewController
51+
52+
@synthesize webView;
53+
54+
- (void)viewDidLoad
55+
{
56+
NSString *path = [[NSBundle mainBundle] pathForResource:@"webViewContent" ofType:@"html"];
57+
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
58+
59+
NSString *htmlString = [[NSString alloc] initWithData:
60+
[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
61+
62+
// to make html content transparent to its parent view -
63+
// 1) set the webview's backgroundColor property to [UIColor clearColor]
64+
// 2) use the content in the html: <body style="background-color: transparent">
65+
// 3) opaque property set to NO
66+
//
67+
webView.opaque = NO;
68+
webView.backgroundColor = [UIColor clearColor];
69+
[self.webView loadHTMLString:htmlString baseURL:nil];
70+
[htmlString release];
71+
}
72+
73+
- (void)dealloc
74+
{
75+
[webView release];
76+
[super dealloc];
77+
}
78+
79+
@end
80+

TransWeb/Prefix.pch

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifdef __OBJC__
2+
#import <Foundation/Foundation.h>
3+
#import <UIKit/UIKit.h>
4+
#endif

TransWeb/ReadMe.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
TransWeb
2+
3+
Demonstrates how to implement UIWebView with a transparent background.
4+
5+
To achieve this you need to make the HTML body's background color transparent by doing the following -
6+
1) set the UIWebView's backgroundColor property to [UIColor clearColor]
7+
2) use the UIWebView's content in the html: <body style="background-color: transparent">
8+
3) the UIWebView's opaque property set to NO
9+
10+
11+
Build Requirements
12+
iOS 4.0 SDK
13+
14+
15+
Runtime Requirements
16+
iPhone OS 3.2 or later
17+
18+
19+
Using the Sample
20+
Launch the TransWeb project using Xcode.
21+
To run in the simulator, set the Active SDK to Simulator. To run on a device, set the Active SDK to the appropriate Device setting. When launched scroll vertically through the web content and observe the transparent background image.
22+
23+
24+
Packaging List
25+
main.m - Main source file for this sample.
26+
AppDelegate.h/.m - The application's delegate to setup its window and view controller content.
27+
MyViewController.h/.m - The main view controller controlling the web view.
28+
29+
30+
Changes from Previous Versions
31+
1.4 - Updated iTunesArtwork.
32+
1.3 - Added iPhone OS 3.2 for deployment SDK. Updated artwork. Upgraded project to build with the iOS 4 SDK.
33+
1.1 - Corrected UIWebView warning of "Turning off phone number detection is not supported on iPhone OS versions prior 3.0."
34+
1.0 - First release.
35+
36+
37+
Copyright (C) 2009-2010 Apple Inc. All rights reserved.

0 commit comments

Comments
 (0)