如何在Adobe After Effects插件的Extendscript中去除IconButton默认边框?
Hey there! I’ve fought this exact stubborn gray border issue with AE’s ExtendScript IconButton before—totally get how frustrating it is when the obvious outline property doesn’t work. Let’s get this sorted for you.
The Problem with Your Current Code
The outline = 0 property doesn’t target the default gray border on IconButton in AE’s ExtendScript environment. That property is meant for a different type of outline, not the component’s built-in border.
Working Solutions
Here are two reliable fixes that should remove the border completely:
1. Use borderStyle and Disable Focus Rings
This is the simplest and most effective fix for most cases. Add these lines to your code:
var myButtonImage = new File("image.png"); // Fixed the extra brackets in your original code var myButton = window.add("iconbutton", undefined, myButtonImage); myButton.size = [30, 30]; // Critical lines to remove borders myButton.borderStyle = "none"; // Turns off the default gray border myButton.drawFocusRing = false; // Prevents a focus outline from appearing when the button is clicked myButton.outline = 0; // Keep your original line as a fallback
borderStyle = "none"directly overrides the component’s default border styling.drawFocusRing = falseensures you don’t get an extra outline when the button is focused (a common gotcha).
2. Custom Graphic Override (For Edge Cases)
If the first method doesn’t work (rare, but possible in older AE versions), you can take full control by manually drawing the button’s state:
var myButtonImage = new File("image.png"); var myButton = window.add("iconbutton", undefined, myButtonImage); myButton.size = [30, 30]; // Disable default rendering myButton.autoDraw = false; // Draw only the icon, no border myButton.onDraw = function() { this.graphics.drawImage(myButtonImage, 0, 0, this.size[0], this.size[1]); };
This bypasses the default button rendering entirely and just draws your icon directly.
Quick Note
Make sure your image.png has a transparent background—if it has a solid background, that might look like a border even after removing the component’s default one!
内容的提问来源于stack exchange,提问作者Phil

