Я использую UIWebView для наложения SVG-изображения на какой-то стандартный интерфейс iOS. В моем
В этом случае я использую SVG для ознакомления с базовым пользовательским интерфейсом. я все еще
Я работаю над этим, поэтому у меня есть несколько вопросов без ответов.
- SVG-анимация не отображается
работать, хотя я могу оказаться
неправильно в этом.
- Я использую только SVG без
ссылки на таблицу стилей .CSS или другое
документы.
- Я использую класс, полученный из
UIWebView, и он покрывает
вся поверхность. Вы могли бы
вероятно, есть меньший UIWebView,
но я не пробовал это.
- Вот простой пример SVG
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
id="tutorialLayout" width="480px" height="320px">
<desc>UI Feature</desc>
<defs>
<rect id="cover" width="480px" height="320px" opacity="0.3" fill="black"/>
</defs>
<g>
<rect id="top" x="000px" y="000px" width="480px" height="290px" opacity="0.3" fill="black"/>
<rect id="bottom" x="000px" y="310px" width="480px" height="010px" opacity="0.3" fill="black"/>
<rect id="left" x="000px" y="290px" width="010px" height="020px" opacity="0.3" fill="black"/>
<rect id="right" x="200px" y="290px" width="280px" height="020px" opacity="0.3" fill="black"/>
<text x="10" y="280" alignment-baseline="bottom"
style="font-size:32; font-family:Arial fill:black;"
>The totals are reported here</text>
</g>
</svg>
5) Вот фрагмент кода для загрузки SVG
NSBundle *bundle = [NSBundle mainBundle];
NSString *svg = @"svg";
[svgView_ addRequest: [NSURL URLWithString: [bundle pathForResource: @"Arrow" ofType: svg ]] seconds: 5];
[svgView_ addRequest: [NSURL URLWithString: [bundle pathForResource: @"t_help" ofType: svg ]] seconds: 15];
[svgView_ addRequest: [NSURL URLWithString: [bundle pathForResource: @"t_layout" ofType: svg ]] seconds: 5];
Реализующий класс
@implementation RAWebView
//! Internal - process next request
- (void) nextRequest {
RAWebRequest *next = [[urlStack_ pop] retain];
if ( next == nil ) {
[self setHidden: TRUE];
} else {
[super loadRequest: [NSURLRequest requestWithURL: [next url]]];
[super setHidden: FALSE];
[super setUserInteractionEnabled: TRUE];
if ( 0 < [next periodSecs] ) {
int64_t delta = 1000000000;
delta *= [next periodSecs];
dispatch_after( dispatch_time( DISPATCH_TIME_NOW, delta),
dispatch_get_main_queue(),
^{ [self nextRequest]; } );
}
[next release];
}
}
//! Add RAWebRequest to queue
- (void) addRequest: (RAWebRequest*) web_request {
if ( urlStack_ == nil ) {
urlStack_ = [[D4iStack alloc] init];
[self setBackgroundColor: [UIColor clearColor]];
[self setOpaque: NO];
}
if ( 0 == [urlStack_ count] ) {
dispatch_after( dispatch_time( DISPATCH_TIME_NOW, 10000 ),
dispatch_get_main_queue(),
^{ [self nextRequest]; } );
}
[urlStack_ push: web_request];
}
//! Add RAWebRequest to queue
- (void) addRequest: (NSURL*) display_url seconds: (NSUInteger) period_secs {
RAWebRequest *request = [[RAWebRequest alloc] initWithUrl: display_url seconds: period_secs];
[self addRequest: request];
[request release];
}
//! On user touch, hide self and empty urlStack
- (UIView*) hitTest: (CGPoint)point withEvent:(UIEvent *)event {
[urlStack_ clear];
[self setHidden: TRUE];
return nil;
}
//! NSObject dealloc
- (void) dealloc {
[urlStack_ clear];
[urlStack_ release];
[super dealloc];
}
@end
@implementation RAWebRequest
@synthesize url = url_, periodSecs = periodSecs_;
//! Init with set values
- (id) initWithUrl: (NSURL*) display_url seconds: (NSUInteger) period_secs {
if (( self = [super init] )) {
url_ = [display_url retain];
periodSecs_ = period_secs;
}
return self;
}
//! NSObject dealloc
- (void) dealloc {
[url_ release];
[super dealloc];
}
@end