This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString* string; // 结果字符串 | |
NSString* string1, string2; //已存在的字符串,需要将string1和string2连接起来 | |
//方法1. | |
string = [NSString initWithFormat:@"%@,%@", string1, string2 ]; | |
//方法2. | |
string = [string1 stringByAppendingString:string2]; | |
//方法3 . | |
string = [string stringByAppendingFormat:@"%@,%@",string1, string2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIColor*)colorWithHexString:(NSString*)stringToConvert{ | |
if([stringToConverthasPrefix:@"#"]) | |
{ | |
stringToConvert = [stringToConvertsubstringFromIndex:1]; | |
} | |
NSScanner*scanner = [NSScannerscannerWithString:stringToConvert]; | |
unsignedhexNum; | |
if(![scannerscanHexInt:&hexNum]) | |
{ | |
returnnil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. 创建一个点击事件,点击时触发labelClick方法 | |
UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)]; | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 100)]; | |
// 2. 将点击事件添加到label上 | |
label addGestureRecognizer:labelTapGestureRecognizer]; | |
label.userInteractionEnabled = YES; // 可以理解为设置label可被点击 | |
// 3. 在此方法中设置点击label后要触发的操作 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*获取设备IPv4地址对应的字符串*/ | |
public static String getIpAddressString() { | |
try { | |
for (Enumeration<NetworkInterface> enNetI = NetworkInterface | |
.getNetworkInterfaces(); enNetI.hasMoreElements(); ) { | |
NetworkInterface netI = enNetI.nextElement(); | |
for (Enumeration<InetAddress> enumIpAddr = netI | |
.getInetAddresses(); enumIpAddr.hasMoreElements(); ) { | |
InetAddress inetAddress = enumIpAddr.nextElement(); | |
if (inetAddress instanceof Inet4Address && !inetAddress.isLoopbackAddress()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pod install --verbose --no-repo-update | |
pod update --verbose --no-repo-update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I use the first | |
—– BEGIN LICENSE —– | |
Michael Barnes | |
Single User License | |
EA7E-821385 | |
8A353C41 872A0D5C DF9B2950 AFF6F667 | |
C458EA6D 8EA3C286 98D1D650 131A97AB | |
AA919AEC EF20E143 B361B1E7 4C8B7F04 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>使用 `WebViewJavascriptBridge`库 | |
/*这段代码是固定的,必须要放到js中*/ | |
function setupWebViewJavascriptBridge(callback) { | |
if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } | |
if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } | |
window.WVJBCallbacks = [callback]; | |
var WVJBIframe = document.createElement('iframe'); | |
WVJBIframe.style.display = 'none'; | |
WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//实时监控网络状态 | |
- (void)KVONetworkChange { | |
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { | |
switch (status) { | |
case AFNetworkReachabilityStatusUnknown:{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Source code recreated from a .class file by IntelliJ IDEA | |
// (powered by Fernflower decompiler) | |
// | |
import android.annotation.SuppressLint; | |
import android.annotation.TargetApi; | |
import android.app.usage.UsageStats; | |
import android.app.usage.UsageStatsManager; | |
import android.content.Context; | |
import android.content.SharedPreferences; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *imgUrl = _dataArray[index][@"url"]; //下一张背景图url | |
UIImage *placeHolder = _baseImgView.image; //使用上一张背景图作为placeholder | |
[_baseImgView sd_setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:placeHolder completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { | |
if (image) | |
CATransition *transition = [CATransition animation]; | |
transition.type = kCATransitionFade; | |
transition.duration = 1.0f; | |
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
[_baseImgView.layer addAnimation:transition forKey:nil]; |
OlderNewer