Light's Blog

The best or nothing.

iOS知识小集-170724

| Comments

JavaScriptCore

1
[self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('audio')[0].play()"];

调整button点击区域

1
2
3
4
self.playBtn.contentMode = UIViewContentModeScaleAspectFit;
self.closeBtn.contentMode = UIViewContentModeScaleAspectFit;
[self.playBtn setImageEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
[self.closeBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 0)];

判断网络状态

1
2
3
4
- (BOOL)connected {
  NetworkStatus internetStatus = [[Reachability reachabilityForInternetConnection] currentReachabilityStatus];
  return internetStatus != NotReachable;
}

Comments