2017-04-11 140 views
0

在Sketh應用Sketch插件開發:有沒有用於Sketch的API來解鎖MSBitmapLayer的大小?

解鎖尺寸按鈕我可以點擊此按鈕以解鎖草圖應用的層的大小。 然後我可以改變圖像的寬高比。 但我想讓我的Sketch插件做這個工作,而不是用我的手點擊按鈕。 是否有Sketch for API解鎖MSBitmapLayer的大小?

我試過「[layer setIsLocked:false]」,但它不是關於大小鎖。

非常感謝。

+0

瀏覽頭文件時,我偶然發現了MSLayer中的一個名爲「constrainProportion」的布爾函數。我想這可能是你正在尋找的......但我不確定 –

回答

0

你正在尋找的特定功能是 setConstrainProportions()

下面是一個例子,它可以幫助您瞭解它

function toggleConstrainProportions(context) { 
    var doc = context.document 
    var selection = context.selection 

    // Toggles the currently selected item(s) 'Constrain Proportions'setting 

    for (var i = 0; i < [selection count]; i++) { 
    var s = [selection objectAtIndex: i] 
    s.frame().setConstrainProportions(!s.constrainProportions()) 
    } 
} 

希望這是有益:)

+0

謝謝。有用。 – July