小编dus*_*ins的帖子

Java中窗口拖动的事件

我正在尝试在Java中实现类似OS X抽屉的功能,因此我将在另一个窗口下隐藏一个窗口.但是当我拖动主窗口(JFrame)时,我需要在移动到下面的辅助窗口(JWindow)时发送更新.

所以这就是这样......

---------------
|             |----------
|   JFrame    |          |
|             |  JWidow  |
|             |          |
|             |          |
|             |          |
|             |-----------
---------------
Run Code Online (Sandbox Code Playgroud)

也就是说,OS X中的ComponentListener不会为componentMoved发送持续更新,只有当您暂停一秒或取消鼠标时才会发送.这似乎与Win/Linux不同,所以我想知道是否有人有不同的解决方案.

在没有完全理解所有内容的情况下,我希望得到并处理任何正在绘制窗口标题栏的内容(它似乎是关于rootpane的东西).我甚至不确定是否可以这样做,但它是我能想到的唯一其他解决方案来确定整个窗口被拖动的时间.

任何帮助表示赞赏!

java macos listener

5
推荐指数
1
解决办法
952
查看次数

使用CoreAnimation动画帧

我正在尝试在滚动视图中为某些子视图的位置设置动画.我想在它们滑入时创建一个特定的效果.我只是通过更改UIView上的帧来使用隐式动画,但是当它们滑入时它看起来太机器人了.因此我希望能够创建一个弹跳效果,它们会滑入,向远处移动,然后回到预期的位置,几乎是滚动视图到达终点时的样子,恰恰相反.

无论如何,我无法通过动画来改变框架的原点.我不确定我缺少什么,因为如果我切换出动画的内容(将第一个//*设置为/*),它可以很好地改变不透明度.

- (void)slideInStories;
{
    float scrollViewContentWidth = 0;

    for (StoryViewController *storyController in storyControllers) {
        NSMutableArray *animationPoints = [NSMutableArray array];
        CGRect viewFrame = storyController.view.frame; 

        //*
        CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"frame"];
        [animationPoints addObject:[NSValue valueWithCGRect:viewFrame]];

        viewFrame.origin.x = scrollViewContentWidth - 10;
        [animationPoints addObject:[NSValue valueWithCGRect:viewFrame]];

        viewFrame.origin.x = scrollViewContentWidth;
        [animationPoints addObject:[NSValue valueWithCGRect:viewFrame]];
        /*/
        CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
        [animationPoints addObject:[NSNumber numberWithFloat:0.75]];
        [animationPoints addObject:[NSNumber numberWithFloat:0.0]];
        [animationPoints addObject:[NSNumber numberWithFloat:0.75]];
        //*/

        [animation setValues:animationPoints];

        [animation setDuration:4.0];

        viewFrame.origin.x = scrollViewContentWidth;
        scrollViewContentWidth += viewFrame.size.width;
        [storyController.view.layer setFrame:viewFrame];
        [storyController.view.layer setOpacity:1.0];
        [storyController.view.layer addAnimation:animation forKey:nil]; …
Run Code Online (Sandbox Code Playgroud)

core-animation objective-c cakeyframeanimation ios

4
推荐指数
1
解决办法
4534
查看次数