iOS:繪圖

来源:http://www.cnblogs.com/leonlincq/archive/2017/08/29/7449311.html
-Advertisement-
Play Games

1、UIBezierPath(貝塞爾曲線) 1-1)、在重寫 drawRect: 方法里使用 使用不難,看 UIBezierPath.h 基本都會用,值得註意的是,顏色設置如下: 下麵是學習過程中的代碼 1-2)、在普通方法里使用,需要畫布。配合 CAShapeLayer 。 註意:1、設置線寬、顏 ...


1、UIBezierPath(貝塞爾曲線)

  1-1)、在重寫 drawRect: 方法里使用

    使用不難,看 UIBezierPath.h 基本都會用,值得註意的是,顏色設置如下:

//設置 線段、填充 顏色
[[UIColor redColor]set];
//設置 線段 顏色
[[UIColor orangeColor]setStroke];
//設置 填充 顏色
[[UIColor yellowColor]setFill];

    下麵是學習過程中的代碼

- (void)drawRect:(CGRect)rect
{
    //矩形
    UIBezierPath *path1 = [UIBezierPath bezierPathWithRect:CGRectMake(20, 20, 50, 50)];
    [[UIColor grayColor]setStroke];
    [path1 stroke];
    //內切圓
    UIBezierPath *path2 = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(100, 20, 50, 50)];
    [[UIColor blueColor]setFill];
    [path2 fill];
    [[UIColor redColor]setStroke];
    [path2 stroke];
    //切4個圓角
    UIBezierPath *path3 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(200, 20, 50, 50) cornerRadius:15.0];
    [[UIColor greenColor]setStroke];
    [path3 stroke];
    //切1-4個圓角(最後一個參數cornerRadii,好像就size.width有效果?)
    UIBezierPath *path4 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(300, 20, 50, 50) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight  cornerRadii:CGSizeMake(15.0, 35.0)];
    [[UIColor whiteColor]setStroke];
    [path4 stroke];
    //弧形
    UIBezierPath *path5 = [UIBezierPath bezierPathWithArcCenter:CGPointMake(50, 120) radius:25.0 startAngle:M_PI endAngle:M_PI/4 clockwise:YES];
    [[UIColor yellowColor]setStroke];
    [path5 stroke];
    
    //畫直線
    UIBezierPath *path6 = [UIBezierPath bezierPath];
    [path6 setLineWidth:3.0];
    [path6 moveToPoint:CGPointMake(100, 100)];
    [path6 addLineToPoint:CGPointMake(150, 100)];
    [path6 addLineToPoint:CGPointMake(150, 150)];
    [path6 addLineToPoint:CGPointMake(100, 150)];
    [path6 addLineToPoint:CGPointMake(100, 100)];
    [path6 addLineToPoint:CGPointMake(200, 125)];
    [path6 addLineToPoint:CGPointMake(150, 150)];
    [path6 closePath];
    path6.usesEvenOddFillRule = YES;
    [[UIColor grayColor]setFill];
    [path6 fill];
    [[UIColor redColor]setStroke];
    [path6 stroke];
    
    //貝塞爾曲線
    UIBezierPath *path7 = [UIBezierPath bezierPath];
    [path7 setLineWidth:5.0];
    [[UIColor orangeColor]setStroke];
    [path7 moveToPoint:CGPointMake(200, 100)];
    [path7 addCurveToPoint:CGPointMake(300, 100) controlPoint1:CGPointMake(250, 150) controlPoint2:CGPointMake(275, 50)];
    [path7 stroke];
    
    //貝塞爾曲線
    UIBezierPath *path8 = [UIBezierPath bezierPath];
    [path8 setLineWidth:5.0];
    [[UIColor purpleColor]setStroke];
    [path8 moveToPoint:CGPointMake(200, 150)];
    [path8 addQuadCurveToPoint:CGPointMake(300, 150) controlPoint:CGPointMake(250, 200)];
    [path8 stroke];
    
    //帶圓心到起始角度線段的弧形
    UIBezierPath *path9 = [UIBezierPath bezierPath];
    [path9 setLineWidth:5.0];
    [[UIColor brownColor]setStroke];
    [path9 moveToPoint:CGPointMake(50, 200)];
    [path9 addArcWithCenter:CGPointMake(50, 200) radius:25.0 startAngle:0.0 endAngle:M_PI clockwise:YES];
    [path9 stroke];
    
    //虛線
    UIBezierPath *path10 = [UIBezierPath bezierPath];
    [path10 setLineWidth:5.0];
    [[UIColor whiteColor]setStroke];
    [path10 moveToPoint:CGPointMake(10, 300)];
    [path10 addLineToPoint:CGPointMake(SCREEN_WIDTH - 10, 300)];
    CGFloat lineDash[] = {10.0,2.0,5.0,5.0};
    //奇數實線,偶數虛線,phase起始偏移
    [path10 setLineDash:lineDash count:4 phase:0];
    [path10 stroke];
}

 

  1-2)、在普通方法里使用,需要畫布。配合 CAShapeLayer 。

    註意:1、設置線寬、顏色、填充等,都由 CAShapeLayer 完成,UIBezierPath 只完成路徑的繪畫。

       2、CAShapeLayer的大小,可以設成屏幕的大小 SCREEN.BOUNDS。UIBezierPath畫完線條後,自動剪裁,如果沒閉合,會自動連接起點、終點剪裁。

    

    下麵是學習過程中的代碼

- (void)drawTest
{
    //矩形
    CGRect rect1 = {20, 20, 50, 50};
    UIBezierPath *path1 = [UIBezierPath bezierPathWithRect:rect1];
    
    CAShapeLayer *shapeLayer1 = [[CAShapeLayer alloc]init];
    shapeLayer1.position = self.layer.position;
    shapeLayer1.bounds = self.layer.bounds;
    shapeLayer1.path = path1.CGPath;
    shapeLayer1.fillColor = [UIColor grayColor].CGColor;
    [self.layer addSublayer:shapeLayer1];


    //內切圓
    CGRect rect2 = {100, 20, 50, 50};
    UIBezierPath *path2 = [UIBezierPath bezierPathWithOvalInRect:rect2];
    
    CAShapeLayer *shapeLayer2 = [[CAShapeLayer alloc]init];
    shapeLayer2.position = self.layer.position;
    shapeLayer2.bounds = self.layer.bounds;
    shapeLayer2.path = path2.CGPath;
    shapeLayer2.fillColor = [UIColor blueColor].CGColor;
    shapeLayer2.strokeColor = [UIColor orangeColor].CGColor;
    shapeLayer2.strokeStart = 0.0;
    shapeLayer2.strokeEnd = 0.7;
    shapeLayer2.lineWidth = 3.0;
    [self.layer addSublayer:shapeLayer2];
    
    //畫線
    UIBezierPath *path3 = [UIBezierPath bezierPath];
    [path3 moveToPoint:CGPointMake(100, 100)];
    [path3 addLineToPoint:CGPointMake(150, 100)];
    [path3 addLineToPoint:CGPointMake(150, 150)];
    [path3 addLineToPoint:CGPointMake(100, 150)];
    [path3 addLineToPoint:CGPointMake(100, 100)];
    [path3 addLineToPoint:CGPointMake(200, 125)];
    [path3 addLineToPoint:CGPointMake(150, 150)];
    
    CAShapeLayer *shapeLayer3 = [[CAShapeLayer alloc]init];
    shapeLayer3.position = self.layer.position;
    shapeLayer3.bounds = self.layer.bounds;
    shapeLayer3.path = path3.CGPath;
    shapeLayer3.fillColor = [UIColor redColor].CGColor;
    shapeLayer3.strokeColor = [UIColor orangeColor].CGColor;
    shapeLayer3.lineWidth = 3.0;
    shapeLayer3.fillRule = kCAFillRuleEvenOdd;
    [self.layer addSublayer:shapeLayer3];
}

 

 

 

附錄:

CGContext 方法

    CGContextGetTypeID(void)
    CGContextSaveGState(CGContextRef cg_nullable c)
    CGContextRestoreGState(CGContextRef cg_nullable c)
    CGContextScaleCTM(CGContextRef cg_nullable c, CGFloat sx, CGFloat sy)
    CGContextTranslateCTM(CGContextRef cg_nullable c, CGFloat tx, CGFloat ty)
    CGContextRotateCTM(CGContextRef cg_nullable c, CGFloat angle)
    CGContextConcatCTM(CGContextRef cg_nullable c,CGAffineTransform transform)
    CGContextGetCTM(CGContextRef cg_nullable c)
    CGContextSetLineWidth(CGContextRef cg_nullable c, CGFloat width)
    CGContextSetLineCap(CGContextRef cg_nullable c, CGLineCap cap)
    CGContextSetLineJoin(CGContextRef cg_nullable c, CGLineJoin join)
    CGContextSetMiterLimit(CGContextRef cg_nullable c, CGFloat limit)
    CGContextSetLineDash(CGContextRef cg_nullable c, CGFloat phase, const CGFloat * __nullable lengths, size_t count)
    CGContextSetFlatness(CGContextRef cg_nullable c, CGFloat flatness)
    CGContextSetAlpha(CGContextRef cg_nullable c, CGFloat alpha)
    CGContextSetBlendMode(CGContextRef cg_nullable c, CGBlendMode mode)
    CGContextBeginPath(CGContextRef cg_nullable c)
    CGContextMoveToPoint(CGContextRef cg_nullable c,
    CGContextAddLineToPoint(CGContextRef cg_nullable c, CGFloat x, CGFloat y)
    CGContextAddCurveToPoint(CGContextRef cg_nullable c, CGFloat cp1x,
    CGContextAddQuadCurveToPoint(CGContextRef cg_nullable c, CGFloat cpx, CGFloat cpy, CGFloat x, CGFloat y)
    CGContextClosePath(CGContextRef cg_nullable c)
    CGContextAddRect(CGContextRef cg_nullable c, CGRect rect)
    CGContextAddRects(CGContextRef cg_nullable c, const CGRect * __nullable rects, size_t count)
    CGContextAddLines(CGContextRef cg_nullable c,
    CGContextAddEllipseInRect(CGContextRef cg_nullable c, CGRect rect)
    CGContextAddArc(CGContextRef cg_nullable c, CGFloat x, CGFloat y, CGFloat radius, CGFloat startAngle, CGFloat endAngle, int clockwise)
    CGContextAddArcToPoint(CGContextRef cg_nullable c, CGFloat x1, CGFloat y1, CGFloat x2, CGFloat y2, CGFloat radius)
    CGContextAddPath(CGContextRef cg_nullable c, CGPathRef cg_nullable path)
    CGContextReplacePathWithStrokedPath(CGContextRef cg_nullable c)
    CGContextIsPathEmpty(CGContextRef cg_nullable c)
    CGContextGetPathCurrentPoint(CGContextRef cg_nullable c)
    CGContextGetPathBoundingBox(CGContextRef cg_nullable c)
    CGContextCopyPath(CGContextRef cg_nullable c)
    CGContextPathContainsPoint(CGContextRef cg_nullable c, CGPoint point, CGPathDrawingMode mode)
    CGContextDrawPath(CGContextRef cg_nullable c, CGPathDrawingMode mode)
    CGContextFillPath(CGContextRef cg_nullable c)
    CGContextEOFillPath(CGContextRef cg_nullable c)
    CGContextStrokePath(CGContextRef cg_nullable c)
    CGContextFillRect(CGContextRef cg_nullable c, CGRect rect)
    CGContextFillRects(CGContextRef cg_nullable c, const CGRect * __nullable rects, size_t count)
    CGContextStrokeRect(CGContextRef cg_nullable c, CGRect rect)
    CGContextStrokeRectWithWidth(CGContextRef cg_nullable c, CGRect rect, CGFloat width)
    CGContextClearRect(CGContextRef cg_nullable c, CGRect rect)
    CGContextFillEllipseInRect(CGContextRef cg_nullable c,CGRect rect)
    CGContextStrokeEllipseInRect(CGContextRef cg_nullable c, CGRect rect)
    CGContextStrokeLineSegments(CGContextRef cg_nullable c, const CGPoint * __nullable points, size_t count)
    CGContextClip(CGContextRef cg_nullable c)
    CGContextEOClip(CGContextRef cg_nullable c)
    CGContextClipToMask(CGContextRef cg_nullable c, CGRect rect, CGImageRef cg_nullable mask)
    CGContextGetClipBoundingBox(CGContextRef cg_nullable c)
    CGContextClipToRect(CGContextRef cg_nullable c, CGRect rect)
    CGContextClipToRects(CGContextRef cg_nullable c, const CGRect *  rects, size_t count)
    CGContextSetFillColorWithColor(CGContextRef cg_nullable c, CGColorRef cg_nullable color)
    CGContextSetStrokeColorWithColor(CGContextRef cg_nullable c, CGColorRef cg_nullable color)
    CGContextSetFillColorSpace(CGContextRef cg_nullable c, CGColorSpaceRef cg_nullable space)
    CGContextSetStrokeColorSpace(CGContextRef cg_nullable c, CGColorSpaceRef cg_nullable space)
    CGContextSetFillColor(CGContextRef cg_nullable c, const CGFloat * cg_nullable components)
    CGContextSetStrokeColor(CGContextRef cg_nullable c, const CGFloat * cg_nullable components)
    CGContextSetFillPattern(CGContextRef cg_nullable c, CGPatternRef cg_nullable pattern, const CGFloat * cg_nullable components)
    CGContextSetStrokePattern(CGContextRef cg_nullable c, CGPatternRef cg_nullable pattern, const CGFloat * cg_nullable components)
    CGContextSetPatternPhase(CGContextRef cg_nullable c, CGSize phase)
    CGContextSetGrayFillColor(CGContextRef cg_nullable c, CGFloat gray, CGFloat alpha)
    CGContextSetGrayStrokeColor(CGContextRef cg_nullable c, CGFloat gray, CGFloat alpha)
    CGContextSetRGBFillColor(CGContextRef cg_nullable c, CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
    CGContextSetRGBStrokeColor(CGContextRef cg_nullable c, CGFloat red, CGFloat green, CGFloat blue, CGFloat alpha)
    CGContextSetCMYKFillColor(CGContextRef cg_nullable c, CGFloat cyan, CGFloat magenta, CGFloat yellow, CGFloat black, CGFloat alpha)
    CGContextSetCMYKStrokeColor(CGContextRef cg_nullable c, CGFloat cyan, CGFloat magenta, CGFloat yellow, CGFloat black, CGFloat alpha)
    CGContextSetRenderingIntent(CGContextRef cg_nullable c, CGColorRenderingIntent intent)
    CGContextDrawImage(CGContextRef cg_nullable c, CGRect rect, CGImageRef cg_nullable image)
    CGContextDrawTiledImage(CGContextRef cg_nullable c, CGRect rect, CGImageRef cg_nullable image)
    CGContextGetInterpolationQuality(CGContextRef cg_nullable c)
    CGContextSetInterpolationQuality(CGContextRef cg_nullable c, CGInterpolationQuality quality)
    CGContextSetShadowWithColor(CGContextRef cg_nullable c, CGSize offset, CGFloat blur, CGColorRef __nullable color)
    CGContextSetShadow(CGContextRef cg_nullable c, CGSize offset, CGFloat blur)
    CGContextDrawLinearGradient(CGContextRef cg_nullable c, CGGradientRef cg_nullable gradient, CGPoint startPoint, CGPoint endPoint, CGGradientDrawingOptions options)
    CGContextDrawRadialGradient(CGContextRef cg_nullable c, CGGradientRef cg_nullable gradient, CGPoint startCenter, CGFloat startRadius, CGPoint endCenter, CGFloat endRadius, CGGradientDrawingOptions options)
    CGContextDrawShading(CGContextRef cg_nullable c, cg_nullable CGShadingRef shading)
    CGContextSetCharacterSpacing(CGContextRef cg_nullable c, CGFloat spacing)
    CGContextSetTextPosition(CGContextRef cg_nullable c, CGFloat x, CGFloat y)
    CGContextGetTextPosition(CGContextRef cg_nullable c)
    CGContextSetTextMatrix(CGContextRef cg_nullable c, CGAffineTransform t)
    CGContextGetTextMatrix(CGContextRef cg_nullable c)
    CGContextSetTextDrawingMode(CGContextRef cg_nullable c, CGTextDrawingMode mode)
    CGContextSetFont(CGContextRef cg_nullable c, CGFontRef cg_nullable font)
    CGContextSetFontSize(CGContextRef cg_nullable c, CGFloat size)
    CGContextShowGlyphsAtPositions(CGContextRef cg_nullable c, const CGGlyph * cg_nullable glyphs, const CGPoint * cg_nullable Lpositions, size_t count)
    CGContextDrawPDFPage(CGContextRef cg_nullable c, CGPDFPageRef cg_nullable page)
    CGContextBeginPage(CGContextRef cg_nullable c, const CGRect * __nullable mediaBox)
    CGContextEndPage(CGContextRef cg_nullable c)
    CGContextRef cg_nullable CGContextRetain(CGContextRef cg_nullable c)
    CGContextRelease(CGContextRef cg_nullable c)
    CGContextFlush(CGContextRef cg_nullable c)
    CGContextSynchronize(CGContextRef cg_nullable c)
    CGContextSetShouldAntialias(CGContextRef cg_nullable c,
    CGContextSetAllowsAntialiasing(CGContextRef cg_nullable c, bool allowsAntialiasing)
    CGContextSetShouldSmoothFonts(CGContextRef cg_nullable c, bool shouldSmoothFonts)
    CGContextSetAllowsFontSmoothing(CGContextRef cg_nullable c,
    CGContextSetShouldSubpixelPositionFonts( CGContextRef cg_nullable c, bool shouldSubpixelPositionFonts)
    CGContextSetAllowsFontSubpixelPositioning( CGContextRef cg_nullable c, bool allowsFontSubpixelPositioning)
    CGContextSetShouldSubpixelQuantizeFonts( CGContextRef cg_nullable c, bool shouldSubpixelQuantizeFonts)
    CGContextSetAllowsFontSubpixelQuantization( CGContextRef cg_nullable c, bool allowsFontSubpixelQuantization)
    CGContextBeginTransparencyLayer(CGContextRef cg_nullable c, CFDictionaryRef __nullable auxiliaryInfo)
    CGContextBeginTransparencyLayerWithRect( CGContextRef cg_nullable c, CGRect rect, CFDictionaryRef __nullable auxInfo)
    CGContextEndTransparencyLayer(CGContextRef cg_nullable c)
    CGContextGetUserSpaceToDeviceSpaceTransform(CGContextRef cg_nullable c)
    CGContextConvertPointToDeviceSpace(CGContextRef cg_nullable c,
    CGContextConvertPointToUserSpace(CGContextRef cg_nullable c,
    CGContextConvertSizeToDeviceSpace(CGContextRef cg_nullable c,
    CGContextConvertSizeToUserSpace(CGContextRef cg_nullable c, CGSize size)
    CGContextConvertRectToDeviceSpace(CGContextRef cg_nullable c,
    CGContextConvertRectToUserSpace(CGContextRef cg_nullable c,
    CGContextSelectFont(CGContextRef cg_nullable c, const char * cg_nullable name, CGFloat size, CGTextEncoding textEncoding)
    CGContextShowText(CGContextRef cg_nullable c, const char * cg_nullable string, size_t length)
    CGContextShowTextAtPoint(CGContextRef cg_nullable c, CGFloat x, CGFloat y, const char * cg_nullable string, size_t length)
    CGContextShowGlyphs(CGContextRef cg_nullable c, const CGGlyph * __nullable g, size_t count)
    CGContextShowGlyphsAtPoint(CGContextRef cg_nullable c, CGFloat x, CGFloat y, const CGGlyph * __nullable glyphs, size_t count)
    CGContextShowGlyphsWithAdvances(CGContextRef cg_nullable c, const CGGlyph * __nullable glyphs, const CGSize * __nullable advances, size_t count)
    CGContextDrawPDFDocument(CGContextRef cg_nullable c, CGRect rect, CGPDFDocumentRef cg_nullable document, int page)

  

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 對象和變數的區別 假如你叫張三,“變數”和“對象”的區別就是“張三”和“你”的區別 再比如: Var st = [40,25]; 上述的完整版是: Var st =new Array(); St[0]=40; St[1]=25; 這意思是將一個數組類型的對象賦值給一個var類型的變數。也可以理解為v ...
  • 我們一般使用webpack熱載入開發SPA應用,但工作中難免會遇到一些多頁面的demo或項目。 故參考 kingvid-chan 的代碼,搭了一個使用HRM開發多頁面web應用的腳手架,剛好也進一步學習webpack。 項目結構很簡單,需要註意的是: 因使用fs等api,所以每次添加新頁面之後,需要 ...
  • [1]效果演示 [2]功能分析 [3]靜態時鐘 [4]動態效果 [5]完整代碼 ...
  • var csns=document.getElementById("csns"); var tcx=csns.getContext("2d"); csns.style.border="1px red solid"; tcx.strokeStyle="#1296DB" tcx.beginPath();... ...
  • router.js html: ...
  • 先聲明下:本文中的switch僅限於JS,我並未查閱過其他編程語言中switch的語法,但有朋友反映在OC中並不適用! 一、switch語句基礎概念 屬於選擇結構,一般用於選擇要執行的多個代碼塊之一。 基本語法 工作原理:首先設置表達式 ,通常是一個變數。隨後表達式的值會與結構中的每個 case 的 ...
  • 網上一查,肯定搜索到繼承的文章真心不少。我這裡就只說一下自己常用的方式: 通常 在編寫一個類的做法是,在構造函數里聲明欄位,在prototype里指定方法。 demo: ...
  • 數組去重 方法一 數組去重 方法一 //利用 filter var arr = [1,4,2,5,6,4,2,7] var arr1 = arr.filter(function(element, index, self){ return self.indexOf(element) == index ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...